1、判断时间格式
function verifyDate(tmpDateValue){
var tmpLength = tmpDateValue.length;
if (tmpLength == 0||tmpLength==null)
{
return true;
}
for (var i = 0; i < tmpLength;i++){
aChar = tmpDateValue.substring(i,i+1);
if(aChar != "-" && (aChar < "0" || aChar > "9")) {
return false;
}
}
if ((tmpLength < 8 || tmpLength > 10) && tmpLength != 0) {
return false;
}
for (var j= 0; j < 4;j++){
aChar = tmpDateValue.substring(j,j+1);
if(aChar < "0" || aChar > "9") {
return false;
}
}
if (tmpDateValue.substring(4,5) != "-" || tmpDateValue.substring(5,6) == "-"){
return false;
}
if (tmpLength == 8){
if (tmpDateValue.substring(6,7) != "-" || tmpDateValue.substring(7,8) == "-" ){
return false;
}
}
if (tmpLength == 9){
if (tmpDateValue.substring(8,9) == "-" ){
return false;
}
}
if (tmpLength == 10){
if (tmpDateValue.substring(7,8) != "-" || tmpDateValue.substring(6,7) == "-" || tmpDateValue.substring(8,9) == "-" || tmpDateValue.substring(9,10) == "-" ){
return false;
}
}
var count=0;
for (var k = 0; k < tmpLength;k++){
aChar = tmpDateValue.substring(k,k+1);
if(aChar == "-") {
count++;
}
}
if (count!=2){
return false;
}
return true;
}
2、判断时间大小
var tmpBeginTime = new Date(start_time.replace(/-/g,"\/"));
var tmpEndTime = new Date(end_time.replace(/-/g,"\/"));
if (tmpBeginTime>tmpEndTime)
{
alert("开始时间不能大于结束时间!");
return false;
}