Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Input Text disabled property

Input Text disabled property

Input Text Object Reference The Input Text object

Example

Disable the text field:

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

The output is:

Try it »


Definition and Usage

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

A disabled element is 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 attribute.


Syntax

Return the disabled attribute:

textObject

.disabled

Set the disabled attribute:

textObject

.disabled=true|false

Attribute values

Value Description
true|false Describes whether the text field is disabled.
  • true - the text field is disabled
  • false - default. The text field is available.
  • |

    Technical details

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

    More examples

    Example

    Check whether the text field is disabled:

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

    x The output is:

    false

    Try it »

    Example

    Disable and enable the text field:

    function disableTxt() {

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

    }

    function undisableTxt() {

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

    }

    Try it »


    Related pages

    HTML Reference Manual: HTML disabled attribute


    Input Text Object Reference The Input Text object