Javascript Reference - HTML DOM Input Reset disabled Property








The disabled property disables or enables a reset button.

Browser Support

disabled Yes Yes Yes Yes Yes

Syntax

Return the disabled property.

var v = resetObject.disabled 

Set the disabled property.

resetObject.disabled=true|false 

Property Values

Value Description
true|false Disable or enable a reset button
  • true - The reset button is disabled
  • false - Default. The reset button is not disabled




Return Value

A Boolean type value, true if the reset button is disabled, otherwise false.

Example

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:





Example 2

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: