I have kept three drop down boxes for DATE, MONTH and YEAR. I want a validation function that will return false if the day entered is more than 29 for the month of FEB. If it is a leap year, it should accept 29 for FEB. I used the following JavaScript. 

It is prompting even if I enter values 27,28 in the date field. Can you just help me out with this?

Here is the JavaScript code..

```
var myDayStr = document.UserReg.Date.value;
        var myMonthStr = document.UserReg.Month.value;
        var myYearStr = document.UserReg.Year.value;
        var myMonth = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
        var validMonthLength = ['',31,28,31,30,31,30,31,31,30,31,30,31];
        var myDateStr = myDayStr + ' ' + myMonthStr + ' ' + myYearStr;

        var myDate = new Date();
        myDate.setFullYear( myYearStr, myMonthStr, myDayStr );

        if ( myDate.getMonth() != myMonthStr ) {
          alert( ' sorry, but "' + myDateStr + '" is NOT a valid date of birth.' );
          return false;
        }
        var testDate = new Date(myYearStr,(myMonthStr-1),myDateStr);
         if ( (myMonthStr == '02') && (myDateStr != testDate.getDate()) ) {
           alert("There is no dates above 28 in February of "+myYearStr);
           return false;
          }
          if (myMonthStr != 2) {
           if (myDateStr > validMonthLength[myMonthStr])
           {
               alert("Invalid date for month chosen");
               return false; }
          }

```