X
HOME HTML5 CSS3 JAVASCRIPT SQL PHP5 JQUERY ANGULAR BOOTSTRAP3 XML MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

Textarea maxLength Property

Textarea Object Reference Textarea Object

Example

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

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

The result of x will be:

30

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

Internet Explorer Firefox Opera Google Chrome Safari

The maxLength property is supported in all major browsers, except Internet Explorer 9 and earlier versions, and Opera 12 and earlier versions.


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 Reference Textarea Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook