两种时间格式正则表达式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

posted @ 2011-12-07 10:13  走路到纽约  阅读(11906)  评论(0编辑  收藏  举报