Thursday, November 11, 2010

Regular expression for validating Date format dd/MM/yyyy

Hi

Use this following Regular Expression Details, This will support leap year also.

^(((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])\/02\/((19|[2-9]\d)\d{2}))|(29\/02\/((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))$


Matches
[29/02/2000], [30/04/2003], [01/01/2003]

Non-Matches
[29/02/2001], [30-04-2003], [1/1/1899]

No comments: