两种时间格式正则表达式HH:mm 和HH:mm:ss
//检查HH:mm function FormateCheck(str) { //var re = /^[0-2][0-9]:[0-5][0-9]$/; var re = /^(?:[01]\d|2[0-3])(?::[0-5]\d)$/; var result = re.test(str); //alert(result); return result; } //检查HH:mm:ss function FormateCheck(str) { //var re = /^[0-2][0-9]:[0-5][0-9]$/; var re = /^(?:[01]\d|2[0-3])(?::[0-5]\d){2}$/; var result = re.test(str); //alert(result); return result; }
s