Textarea maxLength Attribute
Definition and Usage
maxLength
Sets or returns the value of the maxlength property of the text area.
The HTML maxLength attribute specifies the maximum number of characters allowed in a text area.
See also:
HTML Reference Manual:HTML <textarea> maxlength Attribute
Example
Example 1
Get the maximum number of characters allowed in the specific text area:
var x = document.getElementById("myTextarea").maxLength;
Example 2
Change the maximum number of characters allowed in the text area:
document.getElementById("myTextarea").maxLength = "4";
Syntax
Return the maxLength property:
textareaObject.maxLength
Set maxLength Attribute:
textareaObject.maxLength = number
Attribute Value
Value | Description |
---|---|
number | Specifies the maximum number of characters allowed in the text area. |
Technical Details
Return Value: | Number, indicating the maximum number of characters allowed in the text area. |
---|
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | 10.0 | Support | Support | Support |