Skip to content
Related Articles

Related Articles

Improve Article

HTML | DOM Input Submit defaultvalue Property

  • Last Updated : 10 May, 2021

The Input Submit defaultValue Property in HTML DOM is used to set or return the default value of a submit field. This property is used to reflect the HTML value attribute. The main difference between the default value and value is that the default value indicates the default value and the value contains the current value after making some changes. This property is useful to find out whether the Date field has been changed or not.
Syntax: 
 

  • It is used to return the defaultValue property. 
     
submitObject.defaultValue
  • It is used to set the defaultValue property. 
     
submitObject.defaultValue = value

Property Values: It contains single property value value which defines the default value for Input submit field.
Return Value: It returns a string value which represent the default value of the Input submit field.
Example 1: This example illustrates how to return Input submit defaultValue Property.
 

html




<!DOCTYPE html>
<html>
 
<head>
    <title>
        HTML DOM Input Submit defaultvalue Property
    </title>
</head>
 
<bodystyle="text-align:center;">
    <h1>
        GeeksForGeeks
    </h1>
    <h2>
        HTML DOM Input Submit defaultvalue Property
    </h2>
     
    <input type = "submit" id = "Geeks"
            value = "Submit @ geeksforgeeks">
     
<p>
        click on below button to return the Property
    </p>
  
    <button onclick = "myGeeks()">
        Click Here!
    </button>
     
     
    <p id = "GFG"></p>
  
     
    <!-- Script to return submit value Property -->
    <script>
        function myGeeks() {
            var btn = document.getElementById("Geeks").defaultValue;
            document.getElementById("GFG").innerHTML = btn;
        }
    </script>
</body>
 
</html>

Output: 
 

  • Before Clicking On Button: 
     

  • After Clicking On Button: 
     



Example 2: This example illustrates how to set Input submit defaultValue Property. 
 

html




<!DOCTYPE html>
<html>
 
<head>
    <title>
        HTML DOM Input Submit defaultvalue Property
    </title>
</head>
 
<bodystyle="text-align:center;">
    <h1>
        GeeksForGeeks
    </h1>
    <h2>
        HTML DOM Input Submit defaultvalue Property
    </h2>
     
    <input type = "submit" id = "Geeks"
            value = "Submit @ geeksforgeeks">
             
     
<p>
        click on below button
        to set the Property
    </p>
 
     
    <button onclick = "myGeeks()">
        Click Here!
    </button>
     
    <p id = "GFG"></p>
  
     
    <!-- Script to return submit value Property -->
    <script>
        function myGeeks() {
            var btn = document.getElementById("Geeks"
                    ).defaultValue ="GeeksforGeeks";
             
            document.getElementById("GFG").innerHTML
                    = btn;
        }
    </script>
</body>
 
</html>

Output: 
 

  • Before Clicking On Button: 
     

  • After Clicking On Button: 
     

Supported Browsers: The browsers supported by DOM Input Submit defaultValue Property are listed below: 
 

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Apple Safari
  • Opera

 

Attention reader! Don’t stop learning now. Get hold of all the important Comcompetitivepetitve Programming concepts with the Web Design for Beginners | HTML  course.




My Personal Notes arrow_drop_up
Recommended Articles
Page :