Home > categories > Packaging & Printing > Preforms > How could I preform date validation?
Question:

How could I preform date validation?

I Implement web site and I want to preform date validation for date feild how could I do that by using asp 2?

Answer:

you could try a procedure like this below that uses the .NET Globalization Classes. You pass in the date to be checked and the format, and if there's an error then false is returned. 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; } I provided a link to an article that explains this more completely. I hope that helps.

Share to: