Back to HTML

HTML Tutorial

Form Validation

Use built-in validation attributes before adding JavaScript.

HTML includes validation attributes such as required, minlength, maxlength, pattern, min, and max.

Built-in validation gives users fast feedback and reduces unnecessary custom code.

code
<input type="email" required />
<input type="text" minlength="3" maxlength="30" />