Javascript examples for DOM HTML Element:Input Email field
The defaultValue property sets or gets the default value of an email field, which is the value specified in the value attribute.
defaultValue contains the default value, while value contains the current value.
You can use defaultValue property to find out whether the email field have been changed.
Set the defaultValue property with the following Values
Value | Description |
---|---|
value | Sets the default value of the email field |
A String, representing the default value of the email field
The following code shows how to change the default value of an email field:
<!DOCTYPE html> <html> <body> E-mail: <input type="email" id="myEmail" value="a@example.com"> <button type="button" onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from w ww.j a v a2s. co m var x = document.getElementById("myEmail"); x.defaultValue = 'new value'; } </script> </body> </html>