Showing posts with label Date Validators. Show all posts
Showing posts with label Date Validators. Show all posts

Friday, January 2, 2009

Date Validation Expressions

Follwing are different regular expressions used for date validation which you can use in any ASP.NET application to validate date using
RegularExpressionValidator

yyyy/mm/dd pattern
^/d{4}(/)[0-9][1-9](/)[0-3][0-9]$

mm/dd/yyyy format
\d{1,2}/\d{1,2}/\d{2,4}

//for mm/dd/yyyy
(0[1-9]1[012])[- /.](0[1-9][12][0-9]3[01])[- /.](1920)\d\d\

mm/dd/yyyy
((0[1-9][1-9])1[012])/((0[1-9][1-9])[12][0-9]3[01])/(1920)[0-9]{2}

Checks all validations
^((0?[13578]1012)(-\/)(([1-9])(0[1-9])([12])([0-9]?)(3[01]?))(-\/)((19)([2-9])(\d{1})(20)([01])(\d{1})([8901])(\d{1}))(0?[2469]11)(-\/)(([1-9])(0[1-9])([12])([0-9]?)(3[0]?))(-\/)((19)([2-9])(\d{1})(20)([01])(\d{1})([8901])(\d{1})))$