Open In App

HTML | DOM Input Email defaultValue Property

Improve
Improve
Like Article
Like
Save
Share
Report

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. 

HTML




<!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 return Input Email defaultValue Property -->
    <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. 

HTML




<!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 set the Input email defaultValue Property -->
    <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


Last Updated : 30 Aug, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads