Groups | Blog | Home
all groups > asp.net > july 2003 >

asp.net : date validation?


Null
7/27/2003 11:19:57 PM
How to write an IsDate function that actually checks for a particular date
format?

Using try-catch on Convert.ToDateTime(sDate) doesn't catch invalid entry
(i.e. 5/2000).....I want the dates to be input as mm/dd/yyyy OR m/d/yyyy OR
m/d/yy (etc.)....

Any thoughts?

Alvin Bruney
7/28/2003 12:28:47 AM
a regex would come in handy here http://regexlib.com/
or do a cheesy
System.DateTime myDateTime = DateTime.Parse(testString);

and check myDateTime for validity. I prefer regex though

[quoted text, click to view]

AddThis Social Bookmark Button