Firefox Tomorrow

web api instance property

HTMLSelectElement: validity property

View on MDN ↗

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

Value

A ValidityState object.

Example

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

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

Specifications

SpecificationsStandards references are available on the canonical MDN page.

Browser compatibility

Browser compatibilityCompatibility data is available on the canonical MDN page.

See also