Validating date in asp net c
There is an input mask on the textbox which forces input of xx/xx/xxxx.
I am trying to use a regular expression validator to enforce that a correct date is entered. My co-worker found this one on the internet but I can't really tell what it's doing.
I need to validate a date entered in a textfield (but is a Date Time anyway) and display the error to the user if there's some problem, like an invalid date (p.e. If I do insert an invalid date, I get a as expected, but I don't want to display this message to the user.
Is there a way to catch this exception and change the display text?
Thanks for help No you are not, though the fact that you are now using a calendar control is a step in the right direction. in that format, tomorrow's datewould appear as 12/11/2008. i:\x20[AP]M) # required AM or PM )| # 24 hour format ( \d|2[0-3]) #hours (:[0-5]\d)) #required minutes optional seconds ? # if there is a space followed by a digit check for time (? [1-9]|1) # hours (:[0-5]\d) # optional minutes and seconds (? Below is my code: I believe that the dates have to be specified in the current culture of the application.You might want to experiment with setting Culture Invariant Values to true and see if that solves your problem.