Input Text disabledProperty
Example
Disable a text field:
document.getElementById("myText").disabled = true;
The output result is:
Try it yourself »
Definition and Usage
The disabled property sets or returns whether a text field is disabled.
Disabled elements are unusable and unclickable. Disabled elements are usually displayed in gray in the browser.
Browser Support
![]()
All major browsers support the disabled property.
Syntax
Return the disabled property:
textObject.disabled
Set the disabled property:
textObject.disabled=true|false
Property Values
| Value | Description |
|---|---|
| true|false | Describes whether the text field is disabled.
|
Technical Details
| Return value: | A Boolean value, returns true if the text field is disabled, otherwise returns false. |
|---|
More Examples
Example
Check whether a text field is disabled:
var x = document.getElementById("myText").disabled;
xThe output result is:
false
Try it yourself »
Example
Disable and enable a text field:
function disableTxt() {
document.getElementById("myText").disabled = true;
}
function undisableTxt() {
document.getElementById("myText").disabled = false;
}
document.getElementById("myText").disabled = true;
}
function undisableTxt() {
document.getElementById("myText").disabled = false;
}
Try it yourself »
Related Pages
HTML Reference Manual:HTML <input> disabled Attribute
Input Text Object Other Extensions