Click here to Skip to main content
13,292,718 members (66,556 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi all, I'm having problems validating my date, I got a text box (tbDate) with a jquery calendar drop, but I'm still been told that I must validate that date, I've got the following method but it doesn't seem to be working for me, if there is any other way please advise and help, thanks alot.

DateTime validate;
        if (DateTime.TryParse(tbDOB.Text, out validate))
            update.Parameters.AddWithValue("@dob", tbDOB.Text);
            Page.ClientScript.RegisterStartupScript(this.GetType(), "Window", "alert('Enter Valid Date');", true);
Posted 10-Oct-12 1:46am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

U Can validate your date Using Javascript with rejex expression[^]

or if u want to validate in server side just use try.. catch.

   Datetime myDate = Datetime.Parse(someTextBox.Text)
Catch (Exception ex)
   'Not a valid Date
'your Msg Goes Hear....
   'Do Something

Wes101 10-Oct-12 8:28am
thanks alot, it worked first time
vivektiwari97701 10-Oct-12 8:34am
Mark this As Solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.171207.1 | Last Updated 10 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100