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

HTML DOM Textarea disabled property

Textarea disabled property

Textarea Object Reference The Textarea object


Example

Example

Disable a text box:

document

.

getElementById

(

"

myTextarea

"

)

.

disabled

=

true

;

Try it »


Definition and Usage

The disabled property can set or return whether the text box should be disabled.

A disabled input element is neither usable nor clickable. The disabled attribute can be set until some other condition is met (such as selecting a checkbox, etc.).

**Note:** If you want the content of the text box to be read-only, you can use readOnly attribute.


Browser support

property
disabled Yes Yes Yes Yes Yes

Syntax

Set the disabled attribute:

textareaObject.disabled = true|false

Return the disabled attribute:

textareaObject.disabled


Attribute values

Value Description
true|false

Set whether the textarea text box should be disabled.

  • true - disable the text box.
  • false - default. do not disable the text box.
  • |

    Technical Details

    Return value: A boolean, returning whether the text box should be disabled.

    More examples

    Example

    Check whether the textarea element is disabled:

    var

    x

    =

    document

    .

    getElementById

    (

    "

    myTextarea

    "

    )

    .

    disabled

    ;

    Try it »

    Example

    Disable and re-enable the textarea element:

    function

    disableTxt

    (

    )

    {

    document

    .

    getElementById

    (

    "

    myTextarea

    "

    )

    .

    disabled

    =

    true

    ;

    }

    function

    undisableTxt

    (

    )

    {

    document

    .

    getElementById

    (

    "

    myTextarea

    "

    )

    .

    disabled

    =

    false

    ;

    }

    Try it »


    Textarea Object Reference The Textarea object