例子:
// 判断是不是时间格式:HH:CC
function IsTime(num){
var regexp = /^([0-1][0-9]|[2][0-3])(:)([0-5][0-9])$/g;
return regexp.test(num);
}
//调用此方法判断你需要的格式
function check(num) {
if(IsTime(num)) {
alert("这是一个正确的日期格式;" + num);
} else {
alert("日期格式错误;" + num);
}
}