HTMLFormElement: reportValidity() method

Baseline 2023

Newly available

Since March 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

The HTMLFormElement.reportValidity() method returns true if the element's child controls satisfy their validation constraints. When false is returned, cancelable invalid events are fired for each invalid child and validation problems are reported to the user.

Syntax

js
reportValidity()

Return value

true or false

Example

js
document.forms["myform"].addEventListener(
  "submit",
  () => {
    document.forms["myform"].reportValidity();
  },
  false,
);

Specifications

Specification
HTML Standard
# dom-cva-reportvalidity-dev

Browser compatibility

BCD tables only load in the browser