Validating datetime

If I enter 1 January 1000 as the min or max value I get an error saying value cannot be converted to type date, but if I use another format it picks up my entered text as invalid.

Below is my code: I believe that the dates have to be specified in the current culture of the application.

Try Parse will validate whether a value is a valid Date Time object.

The date time picker contains a validation event which may be handled in code; the problem with validating the control using its validation event is that, if the validation includes confirmation of the change, the validation event will fire twice.I needed to tell whether a valid date had been entered into a text box and this is the code that I came up with. Example use based on your original code: //suppose that input string is short date format. "2013/7/5" returns true or "2013/2/31" returns false.If the developer opts to perform the confirmation task in the date time picker's value changed event handler, the user will presented with two confirmation boxes each time the value is changed and then restored to its previous value.Not sure if I'm being overly pedantic there, but Date Time.

Search for validating datetime:

validating datetime-66validating datetime-47validating datetime-43

Hi, use Regular Expression Validator with below regular expression : ^([1-9]\d((0[1-9]|1[012])(0[1-9]|1\d|2[0-8])|(0[13456789]|1[012])(29|30)|(0[13578]|1[02])31)|(([2-9]\d)(0[48]|[2468][048]|[13579][26])|(([2468][048]|[3579][26])00))0229)$ Regards Anant Vijay I don't understand why a lot of people answer this question by saying "you should use the Calendar control instead", or "use the Ajax Toolkit extender"..

Leave a Reply

Your email address will not be published. Required fields are marked *

One thought on “validating datetime”