Open In App

HTML | DOM Input Submit defaultvalue Property

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: 



submitObject.defaultValue
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.




<!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: 

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




<!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: 

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


Article Tags :