Easy Tutorial
❮ Prop Progress Value Prop Canvas Textbaseline ❯

maxLength Property of Textarea

Textarea Object


Example

Retrieve the maximum number of characters allowed in a textarea:

var x = document.getElementById("myTextarea").maxLength;

Definition and Usage

The maxLength property is used to set or return the value of the maxlength attribute of a textarea element.

The maxLength property specifies the maximum number of characters allowed in the textarea element.


Browser Support

Property Chrome IE Firefox Safari Opera
maxLength Yes 10.0 Yes Yes Yes

Syntax

Return the maxLength property:

textareaObject.maxLength

Set the maxLength property:

textareaObject.maxLength = number

Property Value

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 allowed in a textarea:

document.getElementById("myTextarea").maxLength = "4";

Textarea Object

❮ Prop Progress Value Prop Canvas Textbaseline ❯