Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Validate a date
Message
From
15/07/2006 04:08:18
 
 
To
14/07/2006 15:34:12
Jerry Tovar
Dana Corporation Dana It
Maumee, Ohio, United States
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Environment versions
Environment:
ASP.NET
Miscellaneous
Thread ID:
01136539
Message ID:
01136631
Views:
28
Hi,

>I have a ASP.Net webform that contains a textbox where a user should enter a date in mm/dd/yy format.
>
>How can I validate that the user enter a good date?

Take a look at : http://www.codeguru.com/csharp/.net/net_general/netframeworkclasses/article.php/c7547/

Jist of it is:
static bool ValidateDate(String date, String format)
{
   try
   {
      System.Globalization.DateTimeFormatInfo dtfi = new
             System.Globalization.DateTimeFormatInfo();
      dtfi.ShortDatePattern = format;
      DateTime dt = DateTime.ParseExact(date, "d", dtfi);
   }
   catch(Exception)
   {
      return false;
   }
   return true;
}
HTH,
Viv
Previous
Reply
Map
View

Click here to load this message in the networking platform