Richd.nl

a collection of front-end idea's, tutorials and snippets

HTML5

Date Regex

Regex for checking dates.

Format 28-02-2014, 2-2-2014

Everything above 1900

Also leap years

 

^((([0]?[1-9]|[12]\d|3[01])-([0]?[13578]|1[02])-((19|[2-9]\d)\d{2}))|(([0]?[1-9]|[12]\d|30)-([0]?[13456789]|1[012])-((19|[2-9]\d)\d{2}))|(([0]?[1-9]|1\d|2[0-8])-[0]?2-((19|[2-9]\d)\d{2}))|(29-[0]?2-((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))$

 

Leave a Reply

Theme by Anders Norén