# Basic Validation — HTML Fundamentals: Structure, Forms and Accessibility

Source: https://www.skillbyai.com/en/html/html-form-validation

> Validate input in the browser with required, minlength and pattern, and re-check on the server.

## required, pattern, min, max

The browser blocks submission and shows a message until these constraints are met.

```html
<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.

**Quiz:** Which attribute makes a field mandatory before submit?

- [ ] placeholder
- [ ] readonly
- [x] required
- [ ] autofocus

*Answer:* required. `required` blocks form submission until that field has a value.
