Latest web development tutorials

HTML DOM Input Number disabled property

Input Number Object Reference Input Number Object

Examples

Disabling number fields:

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

Results output:


try it"

Definition and Usage

disabled property sets or returns the number fields are disabled.

Use the disabled attribute elements are not available and can not be clicked. Disabled elements are usually displayed on the browser gray.

This property reflects the HTML disabled property.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the disabled attribute

Note: Internet Explorer 9 and earlier versions of IE do not support the use of type = "number" <input> element attributes.


grammar

Returns disabled properties:

numberObject .disabled

Set the disabled attribute:

numberObject .disabled=true|false

Property Value

描述
true|false 描述 number 字段是否可用。
  • number 字段不可用
  • false -默认。 number 字段可用

technical details

return value: Boolean field if the number is not available returns true, false otherwise


More examples

Examples

Check number field is available:

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

try it"

Examples

Disable or enable the number field:

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

try it"


Related Pages

HTML Reference Manual: HTML <the INPUT> Disabled Property


Input Number Object Reference Input Number Object