Javascript examples for DOM HTML Element:Input Email field
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 |
A Boolean, returns true if the email field is disabled, otherwise it returns false
The following code shows how to disable an email field:
<!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>