Since March 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
The reportValidity() method of the ElementInternals interface checks if the element meets any constraint validation rules applied to it.
If reportValidity returns false then a cancelable invalid event is fired on the element.
This method behaves in a similar way to ElementInternals.checkValidity(), however it additionally sends the value of ElementInternals.validationMessage to the user agent for display.
reportValidity()
None.
A boolean value, true if the element meets all validation constraints.
NotSupportedError DOMException
Thrown if the element does not have its formAssociated property set to true.
In the following example ElementInternals.setValidity() is used to indicate that the element does not meet validation rules. Calling reportValidity() returns false, and the value "my message" is sent to the user agent for display.
After calling setValidity again, this time indicating that all rules are marked false, reportValidity() returns true.
let element = document.getElementById("join-checkbox");
element.internals_.setValidity({ valueMissing: true }, "my message");
console.log(element.internals_.reportValidity()); // false
element.internals_.setValidity({});
console.log(element.internals_.reportValidity()); // true
| Specification |
|---|
| HTML> # dom-elementinternals-reportvalidity> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
reportValidity |
77 | 79 | 98 | 64 | 16.4 | 77 | 98 | 55 | 16.4 | 12.0 | 77 | 16.4 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/reportValidity