Easy Tutorial
❮ Prop Node Childnodes Jsref Dowhile ❯

disabled Attribute

Input Text Object

Example

Disable a text field:

document.getElementById("myText").disabled = true;

Output result:


Definition and Usage

The disabled attribute is used to set or return whether the text field is disabled.

Disabled elements are unusable and unclickable. Disabled elements are typically displayed in gray in browsers.


Browser Support

All major browsers support the disabled attribute.


Syntax

Return the disabled attribute:

Set the disabled attribute:

Attribute Values

Value Description
true false Describes whether the text field is disabled. true - The text field is disabled<br> false - Default. The text field is enabled.

Technical Details

| Return Value: | Boolean, returns true if the text field is disabled, otherwise returns false | | --- | --- |


More Examples

Example

Check if a text field is disabled:

var x = document.getElementById("myText").disabled;

x output result:

false

Example

Disable and enable a text field:

function disableTxt() {    document.getElementById("myText").disabled = true;
}
function undisableTxt() {    document.getElementById("myText").disabled = false;
}

Related Pages

HTML Reference: HTML <input> disabled Attribute


❮ Prop Node Childnodes Jsref Dowhile ❯