Input Button disabled Attribute

Definition and Usage

disabled Property to set or return whether the input button should be disabled.

Disabled elements are not available and cannot be clicked. By default, disabled elements are usually displayed in gray in the browser.

This property reflects the HTML disabled attribute.

See also:

HTML Reference Manual:HTML <input> disabled Attribute

Example

Example 1

Disable button:

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

Try it yourself

Example 2

Check if the button is disabled:

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

Try it yourself

Example 3

Enable and disable buttons:

function disableBtn() {
    document.getElementById("myBtn").disabled = true;
}
function undisableBtn() {
    document.getElementById("myBtn").disabled = false;
}

Try it yourself

Syntax

Return the disabled attribute:

buttonObject.disabled

Set the disabled attribute:

buttonObject.disabled = true|false

Attribute Value

Value Description
true|false

Specifies whether the input button should be disabled

  • true - The input button is disabled
  • false - Default. The input button is not disabled

Technical Details

Return value: Boolean value, returned if the input button is disabled true, otherwise return false.

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support