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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top