HTML & CSS
/Intermediate
HTML Validation
Definition
HTML5 includes built-in form validation features that can prevent a form from submitting if the user enters invalid data, without needing to write any JavaScript.
Explain Like I'm New
You can tell the browser: 'This field is required' or 'This field MUST be an email'. If the user tries to submit the form while leaving the field blank or typing gibberish, the browser itself will pop up a red error message and block the submission.
Real World Example
Adding the `required` attribute to a password field so a user can't accidentally submit an empty password when registering.
Common Use Cases
- •Front-end data validation
- •Improving UX with instant feedback
Interactive Example
Interview Questions
basic
- What attribute forces a user to fill out a field before submitting?
intermediate
- Is HTML validation enough to secure your database?