Skip to content

Instantly share code, notes, and snippets.

@stefanzweifel
Created July 22, 2014 06:43
Show Gist options
  • Save stefanzweifel/8a1a74df1f1ae3bebac6 to your computer and use it in GitHub Desktop.
Save stefanzweifel/8a1a74df1f1ae3bebac6 to your computer and use it in GitHub Desktop.
HTML5 validation pattern
<input type="text" pattern="(0[1-9]|1[0-9]|2[0-9]|3[01]).(0[1-9]|1[012]).[0-9]{4}" name="date" placeholder="Enter a date in format dd.mm.yyyy">
@kolipu
Copy link

kolipu commented Jun 24, 2019

ca ne gère pas le mois de février, et voir pour les années si tu autorises l'an 0005

^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0?[13-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)0?2\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment