1. Native HTML5 Client-Side Validation
HTML5 provides built-in attributes that validate user entries before the browser submits data to the server:
| Attribute | Description | Example |
|---|---|---|
required |
Field cannot be left empty. | |
minlength / maxlength |
Specifies minimum and maximum character count. | |
min / max |
Specifies numeric or date boundary limits. | |
pattern |
Enforces a regular expression (RegEx). | pattern="[A-Z]{5}[0-9]{4}[A-Z]{1}" (PAN card) |
2. Complete Validation Example