HTMLTextAreaElement: validity property

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since December 2018.

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:

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

Specifications

Specification
HTML
# the-constraint-validation-api:dom-cva-validity

Browser compatibility

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
validity

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

See also