These notes connect to the contact form I built for HW4.
Built-in HTML validation
required,minlength,maxlength, andpatternattributes help control input.- Semantic types like
<input type="email">add extra validation for free. - Browser handles basic error messages and focus.
Custom validation
- JavaScript can hook into the Constraint Validation API:
checkValidity()to test the field or form.setCustomValidity()to provide a clearer error message.
- We can combine this with our own error
<output>element to show messages in a11y-friendly ways.