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.
On this page
HTMLFormElement: reportValidity() method
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
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
reportValidity |
40 | 17 | 49 | No | 27 | 10.1 | 40 | 40 | 49 | 27 | 10.3 | 4.0 |
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/reportValidity