HTMLTextAreaElement: minLength property - Web APIs | MDN

Value

A number representing the element's minlength if present or -1.

Example

Given the following HTML:

html

<p>
  <label for="comment">Comment</label>
  <textarea id="comment" minlength="10" maxlength="200"></textarea>
</p>

You can use the minLength property to retrieve or set the <textarea>'s minlength attribute value:

js

const textareaElement = document.querySelector("#comment");
console.log(`Element's minLength: ${textareaElement.minLength}`); // "Element's minlength: 10"
textareaElement.minLength = 5; // updates the element's minlength attribute value

Specifications

Specification
HTML
# dom-textarea-minlength

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on by MDN contributors.