HTML DOM Input Number disabled property
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
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 字段是否可用。
|
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;
}
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