← All tutorials

GoCareerGo Tutorials

HTML Tutorial

Tags, attributes, HTML5 APIs and semantic markup — the web's foundation.

How to Validate an HTML Form

HTML5 provides built-in validation attributes — no JavaScript required for common cases.

<input type="email" required />
<input type="text" pattern="[A-Za-z]{3,}" title="At least 3 letters" />
<input type="number" min="1" max="100" />
  • required — blocks submission if the field is empty
  • pattern — validates against a regular expression
  • min/max/step — bound numeric and date inputs
  • element.checkValidity() and :invalid CSS pseudo-class hook into the same system from JS/CSS