The HTMLFormElement.reportValidity()
method returns true
if the element's child controls satisfy their validation constraints. Whenfalse
is returned, cancelable invalid
events are fired for each invalid child and validation problems are reported to the user.
HTMLFormElement.reportValidity()
document.forms["myform"].addEventListener('invalid', function() { //Optional response here. }, false); document.forms["myform"].addEventListener('submit', function() { document.forms["myform"].reportValidity(); }, false);
Specification | Status | Comment |
---|---|---|
WHATWG HTML Living Standard The definition of 'HTMLFormElement.reportValidity()' in that specification. | Living Standard | |
HTML5.1 The definition of 'HTMLFormElement.reportValidity()' in that specification. | Recommendation | Initial definition |
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | 40.0 | 49.0 (49.0) | No support | (Yes) | No support |
Feature | Android | Android Webview | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|
Basic support | ? | 40.0 | ? | ? | ? | ? | 40.0 |
© 2005–2017 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/reportValidity