Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jan 27, 2012 01:37 AM by Decker Dong - MSFT
Member
275 Points
367 Posts
Jan 21, 2012 09:16 AM|LINK
sjnaughton You Could use the validator: [RegularExpression(@"^(([0-2]\d|[3][0-1])\/([0]\d|[1][0-2])\/[2][0]\d{2})$|^(([0-2]\d|[3][0-1])\/([0]\d|[1][0-2])\/[2][0]\d{2}\s([0-1]\d|[2][0-3])\:[0-5]\d\:[0-5]\d)$", ErrorMessage = "Not A DateTime")]
You Could use the validator:
[RegularExpression(@"^(([0-2]\d|[3][0-1])\/([0]\d|[1][0-2])\/[2][0]\d{2})$|^(([0-2]\d|[3][0-1])\/([0]\d|[1][0-2])\/[2][0]\d{2}\s([0-1]\d|[2][0-3])\:[0-5]\d\:[0-5]\d)$", ErrorMessage = "Not A DateTime")]
hi sjnaughton i need small help what will be the valid dates as per the regex you have given and what are invalid. Can you give some samples
All-Star
27308 Points
5458 Posts
MVP
Jan 21, 2012 02:43 PM|LINK
it's a while ago now I think I just got it from www.regexlib.com
Jan 22, 2012 02:11 PM|LINK
Hi Dora, the thread you last replied to seems to be locked, what I did was go to RegExLib.com see it here http://www.regexlib.com/Search.aspx?k=date&c=-1&m=-1&ps=20
118619 Points
18779 Posts
Jan 27, 2012 01:37 AM|LINK
Hello Dora743:)
The mvp's idea is quite nice,it should be ^\d{4}[\-\/\s]?((((0[13578])|(1[02]))[\-\/\s]?(([0-2][0-9])|(3[01])))|(((0[469])|(11))[\-\/\s]?(([0-2][0-9])|(30)))|(02[\-\/\s]?[0-2][0-9]))$
Dora743
Member
275 Points
367 Posts
How to validate dates?
Jan 21, 2012 09:16 AM|LINK
hi sjnaughton i need small help what will be the valid dates as per the regex you have given and what are invalid. Can you give some samples
Mindcracker MVP
http://dorababu-meka.blogspot.in/
sjnaughton
All-Star
27308 Points
5458 Posts
MVP
Re: How to validate dates?
Jan 21, 2012 02:43 PM|LINK
it's a while ago now I think I just got it from www.regexlib.com
Always seeking an elegant solution.
sjnaughton
All-Star
27308 Points
5458 Posts
MVP
Re: How to validate dates?
Jan 22, 2012 02:11 PM|LINK
Hi Dora, the thread you last replied to seems to be locked, what I did was go to RegExLib.com see it here http://www.regexlib.com/Search.aspx?k=date&c=-1&m=-1&ps=20
Always seeking an elegant solution.
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: How to validate dates?
Jan 27, 2012 01:37 AM|LINK
Hello Dora743:)
The mvp's idea is quite nice,it should be ^\d{4}[\-\/\s]?((((0[13578])|(1[02]))[\-\/\s]?(([0-2][0-9])|(3[01])))|(((0[469])|(11))[\-\/\s]?(([0-2][0-9])|(30)))|(02[\-\/\s]?[0-2][0-9]))$