HTML | DOM textarea minlength Property
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:
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML course.
- 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 minlength property.
html
<!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> |
Output:
- Before Clicking On Button:

- After Clicking On Button:

Examples: HTML program to illustrate how to sets the minlength property.
html
<!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> |
Output:
- Before Clicking On Button:

- After Clicking On Button:



