Input Number disabledProperty

Input Number 对象参考手册Input Number Object

Examples

Disable the number field:

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

The output result is:


Try it yourself »

Definition and Usage

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

Elements that use the disabled property are unavailable and unclickable. Disabled elements are usually displayed in gray in the browser.

This property reflects the HTML disabled attribute.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the disabled property

Note:Internet Explorer 9 and earlier IE versions do not support <input> elements with the type="number" attribute.


Syntax

Return the disabled property:

numberObject.disabled

Set the disabled property:

numberObject.disabled=true|false

Property Values

Value Description
true|false Describes whether the number field is available.
  • The number field is unavailable.
  • false - Default. The number field is available.

Technical Details

Return value: Boolean value, returns true if the number field is unavailable, otherwise returns false


More Examples

Example

Check whether the number field is available:

var x = document.getElementById("myNumber").disabled;
xThe output result is:
true

Try it yourself »

Example

Disable or enable the number field:

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

Try it yourself »


Related Pages

HTML Reference Manual:HTML <input> disabled attribute


Input Number 对象参考手册Input Number Object Other Extensions