The disabled
property disables or enables a reset button.
disabled |
Yes | Yes | Yes | Yes | Yes |
Return the disabled property.
var v = resetObject.disabled
Set the disabled property.
resetObject.disabled=true|false
Value | Description |
---|---|
true|false | Disable or enable a reset button
|
A Boolean type value, true if the reset button is disabled, otherwise false.
The following code shows how to check if a Reset button is disabled.
<!DOCTYPE html>
<html>
<body>
<input type="reset" id="myReset" disabled>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<!-- w ww . ja va2s . c o m-->
<script>
function myFunction() {
var x = document.getElementById("myReset").disabled;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows:
The following code shows how to disable and enable a reset button.
<!DOCTYPE html>
<html>
<body>
<!-- w w w.j av a 2 s . c om-->
<input type="reset" id="myReset"><br>
<button onclick="disable()">Disable Reset Button</button>
<button onclick="enable()">Enable Reset Button</button>
<script>
function disable() {
document.getElementById("myReset").disabled = true;
}
function enable() {
document.getElementById("myReset").disabled = false;
}
</script>
</body>
</html>
The code above is rendered as follows: