Javascript examples for DOM HTML Element:Textarea
The maxLength property sets or gets the maxlength attribute of a text area.
The maxLength attribute sets the maximum number of characters allowed in a text area.
Set the maxLength property with the following Values
Value | Description |
---|---|
number | Sets the maximum number of characters allowed in the text area |
A Number, representing the maximum number of characters allowed in the text area
The following code shows how to get the maximum number of characters allowed in a specific text area:
<!DOCTYPE html> <html> <body> Address:<br> <textarea id="myTextarea"> </textarea> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from ww w .j av a 2 s . c o m var v = document.getElementById("myTextarea").maxLength; document.getElementById("demo").innerHTML = v; } </script> </body> </html>