HTML DOM Input Text form Property

The HTML DOM Input Text form property is used for returning the form reference that contains the input text field. If the input text field is outside the form then it will simply return NULL. This property is read-only.


Following is the syntax for input text form property.



Let us look at an example for the Input text form property −

Live Demo

<!DOCTYPE html>
<h1>Input Text form Property</h1>
<form id="NEW_FORM">
USERNAME: <input type="text" id="TEXT1">
<p>Get the form id by clicking on the below button</p>
<button type="button" onclick="formId()">GET FORM</button>
<p id="Sample"></p>
   function formId() {
      var P=document.getElementById("TEXT1");
      document.getElementById("Sample").innerHTML = "The id of the form containing the text field is: "+P ;


This will produce the following output −

On clicking the GET FORM button −