Textarea maxLength property
Example
Get the maximum number of characters that can be entered in the textarea:
var
x
=
document
.
getElementById
(
"
myTextarea
"
)
.
maxLength
;
Try it »
Definition and Usage
The maxLength property is used to set or return the value of the maxlength property of the textarea element.
The maxLength property specifies the maximum number of characters allowed 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
Attribute 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 »
The Textarea object