Is there a way to find which child elements in the form is invalid using the html5 automatic form validation?
I know we can check element by element, by calling checkValidity() method. What I'm seeking is, if there's a shorter way.
For example,
var contactForm = document.getElementById('contact-form');
if (contactForm.checkValidity() == false) {
// something like contactForm.getInvalidChildren() and apply
// different style and error message based on the child type
}
:invalid:not(form):not(fieldset)
– Thrombocyte