Open In App

HTML | DOM Input Submit defaultvalue Property

Last Updated : 23 Sep, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

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 Input submits 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 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>
<body style="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 Defaultvalue 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>
<body style="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 set submit Defaultvalue 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 1 and above
  • Edge 12 and above
  • Firefox 1 and above
  • Apple Safari 1 and above
  • Opera


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads