Valid Date routine

Valid Date routine

I have a current set of javascript that validates to see if a date selected is valid.  My dates are picked from 3 different select boxes; one for month, day, and year.  I'm running into an issue where if someone picks 2/31/2014, it sees it as 3/2/2014 when I really want it to just return invalid.  Presumably this is happening  because February only has 28 days so it's just adding a few more onto it.  I was hoping someone could help me update my code to make it work correctly!  Any help would be much appreciated.

  1. function validateDob(condition) {

  2.             var vYear = DES_GetById("<%= ddlDateOfBirthYear.ClientID%>").value;
  3.             var vMonth = DES_GetById("<%= ddlDateOfBirthMonth.ClientID%>").value;
  4.             var vDay = DES_GetById("<%= ddlDateOfBirthDay.ClientID%>").value;
  5.             var ddlYear = DES_GetById("<%= ddlDateOfBirthYear.ClientID%>")
  6.             var ddlMonth = DES_GetById("<%= ddlDateOfBirthMonth.ClientID%>")
  7.             var ddlDay = DES_GetById("<%= ddlDateOfBirthDay.ClientID%>")

  8.             if (vYear != 0 && vMonth != 0 && vDay != 0) {
  9.                 //var vFull = vMonth + '/' + vDay + '/' + vYear

  10.                 if (isDate(vYear, vMonth, vDay)) {
  11.                     $(ddlYear).removeClass("input-error");
  12.                     $(ddlMonth).removeClass("input-error");
  13.                     $(ddlDay).removeClass("input-error");
  14.                     return 1;
  15.                 }
  16.             }
  17.             $(ddlYear).addClass("input-error");
  18.             $(ddlMonth).addClass("input-error");
  19.             $(ddlDay).addClass("input-error");
  20.             return -1;
  21.         }
  22.         function getYear(d) {
  23.             return (d < 1000) ? d + 1900 : d;
  24.         }
  25.         function isDate(year, month, day) {
  26.             // month argument must be in the range 1 - 12
  27.             month = month - 1; // javascript month range : 0- 11
  28.             var tempDate = new Date(year, month, day);
  29.             if ((getYear(tempDate.getYear()) == year) &&
  30.             (month == tempDate.getMonth()) &&
  31.             (day == tempDate.getDate()))
  32.                 return true;
  33.             else
  34.                 return false
  35.         }