Javascript Reference - HTML DOM Input Submit disabled Property








The disabled property disables or enables a submit button.

Browser Support

disabled Yes Yes Yes Yes Yes

Syntax

Return the disabled property.

var v = submitObject.disabled 

Set the disabled property.

submitObject.disabled=true|false 

Property Values

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




Return Value

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

Example

The following code shows how to get if a Submit button is disabled.


<!DOCTYPE html>
<html>
<body>
<input type="submit" id="mySubmit" disabled>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {<!--from w w  w.j av  a 2 s  .  c o  m-->
    var x = document.getElementById("mySubmit").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 a Submit button.


<!DOCTYPE html>
<html>
<body>
<!--   www.  ja  va  2  s . c om-->
<input type="submit" id="mySubmit">
<button onclick="myFunction()">test</button>
<script>
function myFunction() {
    document.getElementById("mySubmit").disabled = true;
}
</script>
</body>
</html>

The code above is rendered as follows: