Built-in validation attributes
Let the browser validate before you do it again on the server.
HTML · Built-in validation attributesIntermediate
<form>
<label for="age">Age (18-65)</label>
<input id="age" name="age" type="number" min="18" max="65" required>
<label for="zip">Postal code</label>
<input id="zip" name="zip" type="text" inputmode="numeric" pattern="[0-9]{5}" title="Five digits" required>
<label for="site">Website</label>
<input id="site" name="site" type="url" placeholder="https://">
<button type="submit">Send</button>
</form>validationpatternminmaxtitle