




var MonthDaysNormal = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
var MonthDaysLeap   = new Array(31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);


function CheckInteger(sVl){
  res = true;
  if (sVl.length==0) {
    res = false;
    return res;
  }
  for (var i=0;i<sVl.length;i++){
    if ((sVl.charAt(i)<'0')||(sVl.charAt(i)>'9')){
      res = false;
      return res;
    }
  }
  return res;
}


function CheckDate(sDt){
  res = true;
 
  if (sDt.length<10) {
    res = false;
    return res;
  }
  
  if (!(CheckInteger(sDt.substr(0,2))&&CheckInteger(sDt.substr(3,2))&&CheckInteger(sDt.substr(6,4)))){
    return false;
  }
  
  var dy = 1*sDt.substr(0,2);
  var mn = 1*sDt.substr(3,2);
  var yr = 1*sDt.substr(6,4);
  if ((mn<1)||(mn>12)||(yr<1900)||(yr>2900)||(dy<1)||(dy>31)){
    res = false;
    return res;
  }
  var IsLeapYear = ((yr % 4) == 0) && (((yr % 100) != 0) || ((yr % 400) == 0)); 
  var MonthDays = new Array();
  MonthDays = IsLeapYear ? MonthDaysLeap:MonthDaysNormal;

  if (dy>MonthDays[mn-1]){
    res = false;
    return res;
  }
  return res;
}



