Skip to content
Related Articles

Related Articles

HTML | DOM Input Email defaultValue Property
  • Difficulty Level : Basic
  • Last Updated : 11 Mar, 2019

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
My Personal Notes arrow_drop_up
Recommended Articles
Page :