HTML

HTML FORM VALIDATION 

(a quick guide)

TEXT <textarea></textarea> <input type="text"> <input type="email"> <input type="url">

SET THE FIELD TYPE

01

NUMBERS <input type="number"> <input type="range">

DATE-TIME <input type="date"> <input type="time"> <input type="datetime-local"> <input type="week"> <input type="month">

Required - CANNOT BE BLANK <input type="text" required>

FIELD RESTRICTIONS

02

MIN & MAX NUMBER <input type="number" min="1" max="12"> <input type="range" min="0" max="10">

STEP - IN INCREMENTS OF <input type="range" step="2.5">

MIN & MAX CHARACTERS <input type="text" minlength="2" maxlength="8">

Enter "Doge" or "Cate" <input type="text" pattern="Doge|Cate">

CUSTOM PATTERNS

03

Matches (0 to 9) 3 times  <input type="text" pattern="[0-9]{3}">

Start with "T", followed by 3 characters, end with X  <input type="text" pattern="T.{3}X">

 Enter "Doge" (Case Insensitive) <input type="text" pattern="[Dd][Oo][Gg][Ee]">

Matches (0 to 9) 1 to 3 times <input type="text" pattern="[0-9]{1,3}">