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;

Try it yourself

Example 2

Check if the text field is disabled:

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

Try it yourself

Example 3

Enable and disable text fields:

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

Try it yourself

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

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