Skip to content
Related Articles

Related Articles

HTML | DOM Textarea form Property
  • Difficulty Level : Basic
  • Last Updated : 16 Oct, 2020

The DOM Textarea form Property is used to return the text area by reference to the form that contains that text area. It returns the form object if the code successfully runs or if the text area is in the form.
Syntax: 
 

textareaObject.form

Return Value: 
 

  • If text area is not contained in the form then it returns the reference of the form that contains the text area.
  • Otherwise, If text area is not contained in the form then it returns NULL.

Example: HTML program to illustrate the DOM Textarea form Property
 

html




<!DOCTYPE html>
<html>
 
<head>
    <title>DOM Textarea form Property</title>
    <style>
        body {
            text-align: center;
        }
         
        h1,
        h2 {
            text-align: center;
        }
    </style>
</head>
 
<body>
    <h1 style="color: green;">
            GeeksforGeeks
    </h1>
 
    <h2>
        DOM Textarea form Property
    </h2>
 
    <form id="Geeks">
        <textarea id="GFG" name="GFG_text">
            Portal for geeks.
        </textarea>
    </form>
 
    <br>
    <button type="button"
            onclick="myGeeks()">
      Submit
  </button>
    <p id="sudo"> </p>
    <script>
        function myGeeks() {
            var x = document.getElementById("GFG").form;
            document.getElementById("sudo").innerHTML = x;
 
        }
    </script>
</body>
 
</html>

Output: 
Before Clicking On Button: 
 



After Clicking On Button: 
 

Note: Above code prints the object of the form type. To print the id or name of the form use form.id instead of form only in the script.
Supported Browsers: The browser supported by Textarea form Property are listed below: 
 

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

 

full-stack-img

My Personal Notes arrow_drop_up
Recommended Articles
Page :