Input Text disabled Attribute
Definition and Usage
disabled
Sets or returns whether the text field is disabled.
Disabled elements are not available and cannot be clicked. By default, disabled elements are usually displayed in gray in the browser.
See also:
HTML Reference Manual:HTML <input> disabled Attribute
Example
Example 1
Disable text field:
document.getElementById("myText").disabled = true;
Example 2
Check if the text field is disabled:
var x = document.getElementById("myText").disabled;
Example 3
Enable and disable text fields:
function disableTxt() { document.getElementById("myText").disabled = true; } function undisableTxt() { document.getElementById("myText").disabled = false; }
Syntax
Return the disabled attribute:
textObject.disabled
Set the disabled attribute:
textObject.disabled = true|false
Attribute Value
Value | Description |
---|---|
true|false |
Specifies whether the text field should be disabled
|
Technical Details
Return value: | Boolean value, returned if the text field is disabled true ; otherwise return false . |
---|
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |