Input Text disabledProperty

Input Text 对象参考手册Input Text Object

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

Internet Explorer Firefox Opera Google Chrome Safari

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.
  • true - The text field is disabled
  • false - Default. The text field is enabled.

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;
}

Try it yourself »


Related Pages

HTML Reference Manual:HTML <input> disabled Attribute


Input Text 对象参考手册Input Text Object Other Extensions