Skip to content
Related Articles

Related Articles

HTML | DOM textarea minlength Property
  • Last Updated : 24 Apr, 2020

The HTML DOM textarea minlength property is used to set or return the value of the minlength attribute of a textarea field. It specifies the minimum number of characters that have been allowed in the Element.

Syntax:

  • It returns the minLength property.
    textareaObject.minLength
  • It is used to set the minLength property.
    textareaObject.minLength = number

Property Values:

  • number: It specifies a minimum number of characters that are allowed in the textarea element.

Return Value: It returns a numeric value which represents the minimum number of characters that have been allowed in the Textarea field.

Example 1: HTML program to illustrate how to return the maxlength property.



filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<body>
    <center>
        <h1 style="color:green; 
                font-style:italic;">
            GeeksforGeeks
        </h1>
  
        <h2 style="color:green; 
                font-style:italic;">
            DOM Textarea minlength Property
        </h2>
  
        <textarea rows="4" cols="50" 
                id="GFG" minlength="6">
            write here.... 
        </textarea>
        <br><br>
  
        <button onclick="myGeeks()">
            Submit
        </button>
  
        <p id="sudo"></p>
  
        <script>
            function myGeeks() {
  
                // Return max length allowed in the textarea field. 
                var x = document.getElementById("GFG").minLength;
  
                document.getElementById("sudo").innerHTML =
                    "There are only " + x + " minimum characters" +
                    "are allowed in a Textarea Field.";;
            
        </script>
</body>
  
</html>

chevron_right


Output:

  • Before Clicking On Button:
  • After Clicking On Button:

Examples: HTML program to illustrate how to sets the minlength property.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<body>
    <center>
        <h1 style="color:green; 
                font-style:italic;">
            GeeksforGeeks
        </h1>
  
        <h2 style="color:green; 
                font-style:italic;">
            DOM Textarea minlength Property
        </h2>
  
        <textarea rows="4" cols="50" id="GFG" minlength="6">
            write here.... 
        </textarea>
        <br>
        <br>
  
        <button onclick="myGeeks()">
            Submit
        </button>
  
        <p id="sudo"></p>
  
        <script>
            function myGeeks() {
  
                // Return max length allowed in the textarea field. 
                var x = document.getElementById("GFG").minLength = "9";
  
                document.getElementById("sudo").innerHTML =
                    "There are only " + x + " minimum characters" +
                    "are allowed in a Textarea Field.";;
            
        </script>
</body>
  
</html>

chevron_right


Output:

  • Before Clicking On Button:
  • After Clicking On Button:

full-stack-img

My Personal Notes arrow_drop_up
Recommended Articles
Page :