function DateIf(year,month,day)
 {
   /* var year=form2.year1.value; 
    var month=form2.month1.value; 
    var day=form2.day1.value; */
    if (month==2) 
      { 
        if((year%4==0 && year%100!=0) || (year%400==0)) 
          { 
            if(day>29) 
              { 
        return false;
              } 
         } 
       else 
         { 
            if(day>28) 
              { 
         return false;
               } 
         } 
      } 
    if((month==4)||(month==6)||(month==9)||(month==11)) 
      { 
         if(day>30) 
         { 
         return false;
          } 
      }
  return true;
 }

解决方案 »

  1.   

    vbscript-------------->IsDate Function
      

  2.   

    function checkDate(str) {
    if ((str.length != 8) || !checkNumber(str))
    return false;
    var year  = str.substring(0, 4);
    var month = str.substring(4, 6);
    var day   = str.substring(6, 8);
    dayOfMonth = new Array(31,29,31,30,31,30,31,31,30,31,30,31);
    if ((month < 1) || (month > 12))
    return false;
    if ((day < 1) || (day > dayOfMonth[month - 1])) 
    return false;
    if (!checkLeapYear(year) && (month == 2) && (day == 29))
    return false;
    return true;
    }
    function checkNumber(str) {
        var i;
        var len = str.length;
        var chkStr = "1234567890";
        if (len == 1) {
    if (chkStr.indexOf(str.charAt(i)) < 0) {
        return false;
    }
    } else {
    if ((chkStr.indexOf(str.charAt(0)) < 0) || (str.charAt(0) == "0")) {
        return false;
    }
        for (i = 1; i < len; i++) {
    if (chkStr.indexOf(str.charAt(i)) < 0) {
        return false;
    }
    }
    }
        return true;
    }
      

  3.   

    function checkLeapYear(year) {
    if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) {
    return true;
    }
    return false;
    }
      

  4.   

    根据event.keyCode的数值来判断!