MDN self-hosted library · e01.org

HTMLTextAreaElement: validity property

HTML DOM

Open notebook · 1 cells web-api-instance-property upstream source

HTML DOM

The validity read-only property of the HTMLTextAreaElement interface returns a ValidityState object that represents the validity states this element is in.

Value

A ValidityState object.

Examples

The following example gets the validity state of a text area element and processes it if it is not valid:

const textArea = document.getElementById("myTextArea");
const validityState = textArea.validity;
if (!validityState.valid) {
  // Test each validity state
}

Specifications

Browser compatibility

See also