Textarea maxLengthProperty
Example
Get the maximum number of characters that can be entered in the textarea:
var x = document.getElementById("myTextarea").maxLength;
Try it yourself »
Definition and Usage
The maxLength property is used to set or return the value of the maxlength attribute of the textarea element.
The maxLength property specifies the maximum number of characters allowed to be entered in the textarea element.
Browser Support
| Property | |||||
|---|---|---|---|---|---|
| maxLength | Yes | 10.0 | Yes | Yes | Yes |
Syntax
Return the maxLength property:
textareaObject.maxLength
Set the maxLength property:
textareaObject.maxLength = number
Property Values
| Value | Description |
|---|---|
| number |
Specifies the maximum number of characters allowed in the textarea element. |
Technical Details
| Return Value: | A number representing the maximum number of characters allowed in the textarea element. |
More Examples
Example
Set the maximum number of characters that can be entered in the textarea:
document.getElementById("myTextarea").maxLength = "4";
Try it yourself »
Other Extensions
Textarea Object