HTML | DOM Input Email defaultValue Property
The Input Email defaultValue property in HTML DOM is used to set or return the default value of Email Field. This property is used to reflect the HTML value attribute. The main difference between the default value and value property is that default value indicate the default value specified in the attribute while the value contains the current value after making some changes. This property is useful when we want to find out whether the email field have been changed or not.
Syntax:
- It is used to return the defaultValue property.
emailObject.defaultValue
- It is used to set the defaultValue property.
emailObject.defaultValue = value
Property Values: It contains single property value value which defines the default value for Email Field.
Return Value: It returns a string value which represent the default value of the Email Field.
Example 1: This example returns the Input Email defaultValue property.
<!DOCTYPE html> <html> <head> <title> HTML DOM Input Email defaultValue Property </title> </head> <body style="text-align:center;"> <h1> GeeksforGeeks</h1> <h2>DOM Input Email defaultValue Property</h2> E-mail: <input type="email" id="email" value="careers@geeksforgeeks.org"> <button onclick="myGeeks()"> Click Here! </button> <p id="GFG" style="font-size:25px;color:green;"></p> <!-- Script to access input element with type email attribute --> <script> function myGeeks() { var em = document.getElementById("email").defaultValue; document.getElementById("GFG").innerHTML = em; } </script> </body> </html> |
Output:
Before clicking on the button:

After clicking on the button:

Example 2: This example sets Input Email defaultValue property.
<!DOCTYPE html> <html> <head> <title> HTML DOM Input Email defaultValue Property </title> </head> <body style="text-align:center;"> <h1> GeeksforGeeks</h1> <h2>DOM Input Email defaultValue Property</h2> E-mail: <input type="email" id="email" value="careers@geeksforgeeks.org"> <button onclick="myGeeks()"> Click Here! </button> <p id="GFG" style="font-size:25px;color:green;"></p> <!-- Script to access input element with type email attribute --> <script> function myGeeks() { var em = document.getElementById("email").defaultValue = "manaschhabra22@gmail.com" document.getElementById("GFG").innerHTML = "The value was changed to " + em; } </script> </body> </html> |
Output:
Before clicking on the button:

After clicking on the button:

Supported Browsers: The browser supported by DOM input Email defaultValue property are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Recommended Posts:
- HTML | DOM Input URL defaultValue Property
- HTML | DOM Input Text defaultValue Property
- HTML | DOM Input Search defaultValue Property
- HTML | DOM Input Number defaultValue Property
- HTML | DOM Input Password defaultValue Property
- HTML | DOM Input Week defaultValue Property
- HTML | DOM Input Color defaultValue Property
- HTML | DOM Input Time defaultValue Property
- HTML | DOM Input Month defaultValue Property
- HTML | DOM Input Email name Property
- HTML | DOM Input Email value Property
- HTML | DOM Input Email pattern Property
- HTML | DOM Input Email type Property
- HTML | DOM Input Email Placeholder Property
- HTML | DOM Input Email disabled Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



