Javel's notes

TIL; check validity & report validity

No need to call form.checkValidity() after a form has been submitted. That verification has already been performed on submission.

In a React component, the function passed to onSubmit attribute is only executed when the form is valid. Errors are shown to the user as a tooltip otherwise.

That being said, it's still possible to use element.reportValidity() to force the browser to perform this verification, without submitting the form.

Sources

© Joris Langlois 2023