Javascript Reference - HTML DOM Input Email disabled Property








The disabled property disables or enables an email field.

Browser Support

disabled Yes 10.0 Yes Yes Yes

Syntax

Return the disabled property.

var v = emailObject.disabled 

Set the disabled property.

emailObject.disabled=true|false

Property Values

Value Description
true|false Disable or enable an email field
  • true - The email field is disabled
  • false - Default. The email field is not disabled




Return Value

A Boolean type value, true if the email field is disabled, otherwise false.

Example

The following code shows how to get if an email field is disabled.


<!DOCTYPE html>
<html>
<body>
<!--from   w  w w.j  a  v a  2  s . c  om-->
E-mail: <input type="email" id="myEmail" disabled>
<button onclick="myFunction()">test</button>
<p id="demo"></p>

<script>
function myFunction() {
    var x = document.getElementById("myEmail").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 an email field.


<!DOCTYPE html>
<html>
<body>
<!--   w ww  .  j  a  va 2  s . c  om-->
E-mail: <input type="email" id="myEmail"><br><br>

<button onclick="disableBtn()">Disable Email Field</button>
<button onclick="enableBtn()">Enable Email Field</button>

<script>
function disableBtn() {
    document.getElementById("myEmail").disabled = true;
}
function enableBtn() {
    document.getElementById("myEmail").disabled = false;
}
</script>

</body>
</html>

The code above is rendered as follows: