Input Email disabled Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Email field

Description

The disabled property sets or gets whether an email field should be disabled.

This property reflects the HTML disabled attribute.

Set the disabled property with the following Values

Value Description
true|false Sets whether an email field should be disabled
  • true - The email field is disabled
  • false - Default. The email field is not disabled

Return Value

A Boolean, returns true if the email field is disabled, otherwise it returns false

The following code shows how to disable an email field:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

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() {//from w  ww  .  j  a va 2s.com
    document.getElementById("myEmail").disabled = true;
}

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

Related Tutorials