Input Number disabled attribute

Definition and Usage

disabled Attribute to set or return whether the number field 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 Atribute

Example

Example 1

Disable the number field:

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

Try it yourself

Example 2

Check if the number field is disabled:

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

Try it yourself

Example 3

Disable and enable the number field:

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

Try it yourself

Syntax

Return disabled attribute:

numberObject.disabled

Set disabled attribute:

numberObject.disabled = true|false

Attribute Value

Value Description
true|false

Specify whether the numeric field should be disabled.

  • true - Numeric field is disabled
  • false - Default. Numeric field is not disabled

Technical Details

Return value: Boolean value, if the numeric field is disabled, it will return true; otherwise return false.

Browser Support

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