
function CheckDate(val,tp)
{
 var INDate;	
 var separate;
 if(tp==1){	
	 INDate=val;
 }else{
	 if(val.split(" ").length!=2) return true;
	 if(isNaN(val.split(" ")[1].split(":")[0])||val.split(" ")[1].split(":")[0]<0||val.split(" ")[1].split(":")[0]>24) return true;
	 if(isNaN(val.split(" ")[1].split(":")[1])||val.split(" ")[1].split(":")[1]<0||val.split(" ")[1].split(":")[1]>60) return true;
	 INDate=val.split(" ")[0];
	 
 }
 if (INDate=="")
    {return true;}
 subYY=INDate.substr(0,4)
 if(isNaN(subYY) || subYY<=0){
  return true;
 }
 //转换月份
 if(INDate.indexOf('-',0)!=-1){ separate="-"}
/* else{
  if(INDate.indexOf('/',0)!=-1){separate="/"}
  else {return true;}
  }*/
  area=INDate.indexOf(separate,0)
  subMM=INDate.substr(area+1,INDate.indexOf(separate,area+1)-(area+1))
  if(isNaN(subMM) || subMM<=0){
  return true;
   
 }
  if(subMM.length<2){subMM="0"+subMM}
 //转换日
 area=INDate.lastIndexOf(separate)
 subDD=INDate.substr(area+1,INDate.length-area-1)
 if(isNaN(subDD) || subDD<=0){
  return true;
  
 }
 if(eval(subDD)<10){subDD="0"+eval(subDD)}
 NewDate=subYY+"-"+subMM+"-"+subDD
 if(NewDate.length!=10){return true;}
    if(NewDate.substr(4,1)!="-"){return true;}
    if(NewDate.substr(7,1)!="-"){return true;}
 var MM=NewDate.substr(5,2);
 var DD=NewDate.substr(8,2);
 if((subYY%4==0 && subYY%100!=0)||subYY%400==0){ //判断是否为闰年
  if(parseInt(MM)==2){
   if(DD>29){return true;}
  }
 }else{
  if(parseInt(MM)==2){
   if(DD>28){return true;}
  } 
 }
 var mm=new Array(1,3,5,7,8,10,12); //判断每月中的最大天数
 var mmx=new Array(4,6,9,11);
 for(i=0;i< mm.length;i++){
  if (parseInt(MM) == mm[i]){
  	if(parseInt(DD)>31){return true;}
  }
 }
 for(j=0;j< mmx.length;j++){
  if (parseInt(MM) == mmx[j]){
  	if(parseInt(DD)>30){return true;}
  }
 }
 
 if(parseInt(MM)>12){return true;}
   return false;
  
}
