Lesson 17 / 28
Basic Validation
Built-in attributes that check input before submit.
required, pattern, min, max
The browser blocks submission and shows a message until these constraints are met.
<input type="text" required minlength="3">
<input type="number" min="1" max="10">
<input type="text" pattern="[A-Za-z]+" title="Letters only">Not a security fence
HTML validation runs in the browser and can be bypassed — always re-validate on the server too.
Quick check: Which attribute makes a field mandatory before submit?
- required
- placeholder
- readonly
Answer
required — `required` blocks form submission until that field has a value.