help - need to validate date and time in c#+asp.net

  • Thread starter Thread starter Frank Rocco
  • Start date Start date
F

Frank Rocco

Hello,


What is the best way to validate a textbox to see if it contains a valid
date or a valid time or both?

Thanks

Frank
 
You could either cast the value as a date and catch the exception if it
isn't one, or you could read up on Regular Expressions and use one to
validate the format.

RegExs are more elegant, but catching the exception is quick, dirty, and
effective.
 
Thanks Jeff, I'll look at the RegExp option.
Anyone have one already coded?
This seems like it would be a common thing to have.

Regards,

Frank
 
Back
Top