Favorites

DOM HTMLFormElement.checkValidity() Method

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
HTMLFormElement.checkValidity()
DOM HTMLFormElement MethodThis method is supported by all modern browsers.
Updated 28th November 2026

The checkValidity() method checks whether every field in a form passes its validation rules. reportValidity() also shows the browser's error messages.

Description

The checkValidity() method returns whether all the form's controls satisfy their validation constraints, such as required, type="email", min and pattern. Invalid controls fire an invalid event. reportValidity() does the same but also shows the browser's error message and focuses the first invalid field. Both exist on individual inputs too, and setCustomValidity() adds your own rules.

Validation runs on every control that takes part in validation; disabled and read-only fields, and buttons, are skipped. Listening for the invalid event on fields lets you show your own error messages, and the CSS :user-invalid pseudo-class styles invalid fields only after the user has interacted with them.

The browser's built-in checks are a convenience for users, not a security measure, since anyone can bypass them; always validate data again on the server.

Syntax

form.checkValidity()
form.reportValidity()

Return Value

true if every control in the form is valid, otherwise false.

Example

<form id="f">
  <input name="email" type="email" required>
  <input name="age" type="number" min="18" value="20">
</form>
const form = document.getElementById('f');
console.log(form.checkValidity());
form.elements.email.value = 'sam@example.com';
console.log(form.checkValidity());
form.elements.age.value = 12;
console.log(form.checkValidity(), form.elements.age.validationMessage);

Browser Support

The following information will show you the current browser support for the HTMLFormElement.checkValidity() method. Hover over a browser icon to see the version that first introduced support for this method.

This method is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee