Get the maximum number of characters allowed in a specific text area:
var x = document.getElementById("myTextarea").maxLength;
Click the button to display the value of the maxlength attribute in the text area.
<!DOCTYPE html> <html> <body> Address:<br> <textarea id="myTextarea" maxlength="30"> PO 1234, Main Street U.S.A. New York</textarea> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from w ww . ja v a 2 s . co m var x = document.getElementById("myTextarea").maxLength; document.getElementById("demo").innerHTML = x; } </script> </body> </html>
The maxLength property sets or gets the value of the maxlength attribute of a text area.
The maxLength attribute specifies the maximum number of characters allowed in a text area.
The maxLength property accepts and returns a number type value.