Disable an email field:
document.getElementById("myEmail").disabled = true;
Click the button to disable the email field.
<!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 |
---|---|
true | The 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.