validate date field in javascript or jquery

I have a datefield . how can i make sure the date entered is valid date? please help

I already use ajaxmask, that allows only entry of numbers in the format 99/99/9999. on top of this I need to make sure this a valid date that SQL server will accept.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Try this:
if ( === "[object Date]" ) {
  // it is a date
  if ( isNaN( d.getTime() ) ) {  // d.valueOf() could also work
    // date is not valid
  else {
    // date is valid
else {
  // not a date

Open in new window

In the above, "d" is the variable you are checking to see if it is a valid date object, then whether it is a valid date or not.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
your question has been answered by nap0leon correctly
just to avoid further problems, format your date before sending it to SQL by sending it as YYYYMMDD
without any date separators so you can avoid any single configuration problems between clients and servers
TrialUserAuthor Commented:
I tried the isNan but it is not catching :- "11/11/1111" or "99/99/9999".

However in th code when I do (DateTime.Parse("txtDate.text")
then I get an error. Please help.
May be is there a valid data range I can check to see if the date is in that range?

TrialUserAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.