Get to know MDN better
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The maxLength property of the HTMLTextAreaElement interface indicates the maximum number of characters (in UTF-16 code units) allowed to be entered for the value of the <textarea> element, and the maximum number of characters allowed for the value to be valid. It reflects the element's maxlength attribute. -1 means there is no limit on the length of the value.
Note: Browsers generally prevent users from entering more characters than the maxlength attribute allows. Should the length be longer, the element is considered invalid and the ValidityState object's tooLong property will be true.
A number representing the element's maxlength if present, or -1.
Given the following HTML:
You can use the maxLength property to retrieve or set the <textarea>'s maxlength attribute value:
| HTML # dom-textarea-maxlength |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Jun 24, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.