THE WORLD'S LARGEST WEB DEVELOPER SITE

Textarea maxLength Property

❮ Textarea Object

Example

Get the maximum number of characters allowed in a specific text area:

var x = document.getElementById("myTextarea").maxLength;
Try it Yourself »

Definition and Usage

The maxLength property sets or returns the value of the maxlength attribute of a text area.

The maxLength attribute specifies the maximum number of characters allowed in a text area.


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 text area

Technical Details

Return Value: A Number, representing the maximum number of characters allowed in the text area

More Examples

Example

Change the maximum number of characters allowed in a text area:

document.getElementById("myTextarea").maxLength = "4";
Try it Yourself »

Related Pages

HTML reference: HTML <textarea> maxlength attribute


❮ Textarea Object