Javascript DOM HTML Input Email disabled Property set

Introduction

Disable an email field:

document.getElementById("myEmail").disabled = true;

Click the button to disable the email field.

View in separate window

<!DOCTYPE html>
<html>
<body>

E-mail: <input type="email" id="myEmail">
<button onclick="myFunction()">Test</button>

<script>
function myFunction() {//w  w w . j  av  a  2 s  .c  om
  document.getElementById("myEmail").disabled = true;
}
</script>

</body>
</html>

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

This property mirrors the HTML disabled attribute.

The disabled property accepts and returns a boolean value.

Property Values

Value Description
trueThe email field is disabled
false Default. The email field is not disabled

The disabled property returns true if the email field is disabled, otherwise it returns false.




PreviousNext

Related