Validating date in textbox in asp net
(You still need to check server-side, anyone can defeat client-side validation either knowingly or unwittingly.) -- Joe (Microsoft MVP - XML)my 2cents if I may - Why let the user enter a date, I always use a date picker pop up like most web sites do.
users are used to this, date formats arnt an issue.....many things in the pro's list to go against IMO Wind is your friend Matt Hi Matt Well, i am using AJAX for date.
In my humble opinion, both of these controls are visually terrible.
(This i leave for you to figure out) Thanks, Ashwani Ahhh my bad.
Been using 2.0 for too long i guess :) I still dont recommend a try catch (and am going to look into the tryparse as it is expensive to use try catchs.
In that case write a simple utility (I have them for integers, decimal etc) that uses regular expressions to validate the date Dear Frd, Just try dd/mm/yyyy Format In regular Expression (optional mm,optional dd) ([1-9]|0[1-9]|[0-9]|3)[- /.]([1-9]|0[1-9]|1)[- /.][0-9]$ mm/dd/yyyy (optional mm,optional dd) ^([1-9]|0[1-9]|1)[- /.]([1-9]|0[1-9]|[0-9]|3)[- /.][0-9]$ mm/dd/yyyy (Exact Format) ^(\d)/([0-3]\d)/(\d)$ Regular Expression in Discussion You can use any culture that supports the dd-mm-yy format like the french one, for example to format the date time now in a format dd-mm-yy i can do as follow: culture Info culture = new cultureinfo("fr-FR"); string o Formated Date = dt Now.
I want date in a dd/mm/yyyy format with validation in Text Box . As I got date with dd/mm/yyyy but it will also accept 32/02/2005. Also when I compare two textbox it will not evalute properly. So I had used Compare Validator, & select type="date" but it will not evalute. Thanking You, One thing that must be kept in mind when using Asp.