Input Text disabled property
Example
Disable the text field:
document.getElementById("myText").disabled = true;
The output is:
Try it »
Definition and Usage
The disabled property is used to set or return whether the text field is disabled.
A disabled element is unusable and unclickable. Disabled elements are usually displayed in gray in the browser.
Browser support

All major browsers support the disabled attribute.
Syntax
Return the disabled attribute:
textObject
.disabled
Set the disabled attribute:
textObject
.disabled=true|false
Attribute values
| Value | Description |
|---|---|
| true|false | Describes whether the text field is disabled.
|
Technical details
| Return Value: | Boolean, returns true if the text field is disabled, otherwise returns false |
|---|
More examples
Example
Check whether the text field is disabled:
var x = document.getElementById("myText").disabled;
x The output is:
false
Try it »
Example
Disable and enable the text field:
function disableTxt() {
document.getElementById("myText").disabled = true;
}
function undisableTxt() {
document.getElementById("myText").disabled = false;
}
Try it »
Related pages
HTML Reference Manual: HTML disabled attribute
The Input Text object