Open In App

HTML | DOM Input Button form Property

Last Updated : 24 Aug, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

The DOM Input Button form Property in HTML DOM is used for returning the reference to the form containing the input Button field is. It is read only property that returns a form object on success. 

Syntax: 

buttonObject.form

Return Values: It returns a string value which specify the reference of the form containing the Input Button field.

Example: Below program illustrates the use of Input Button form property.

HTML




<!DOCTYPE html>
<html>
<head>
    <style>
        h1 {
            color: green;
        }
    </style>
</head>
<body style="text-align:center;">
    <h1>GeeksForGeeks</h1>
    <h2>
      DOM Input Button form Property
      </h2>
    <form id="myGeeks">
        <!-- Assigning button id -->
        <input type="button"
               id="GFG"
               onclick="myGeeks()"
               name="Geek_button"
               value="Submit">
    </form>
    <p id="sudo"
       style="color:green;
              font-size:25px;">
      </p>
 
 
    <script>
        function myGeeks() {
 
            // Return Input Button form Property
            var g =
                document.getElementById(
                  "GFG").form.id;
           
            document.getElementById(
              "sudo").innerHTML = g;
        }
    </script>
</body>
</html>


Output: 
Before Clicking On Button: 

After Clicking On Button: 

Supported Browsers: The browsers supported by DOM input Button form property are listed below: 

  • Google Chrome 1 and above
  • Firefox 1 and above
  • Opera 
  • Safari 1 and above
  • Edge 12 and above


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads