Back to Content

HTMLTextAreaElement: validity property

files/en-us/web/api/htmltextareaelement/validity/index.md

latest944 B
Original Source

{{APIRef("HTML DOM")}}

The validity read-only property of the {{domxref("HTMLTextAreaElement")}} interface returns a {{domxref("ValidityState")}} object that represents the validity states this element is in.

Value

A {{domxref("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

{{Specifications}}

Browser compatibility

{{Compat}}

See also