首页 > 编程 > Regex > 正文

JS 正则 时间验证

2020-03-16 21:14:59
字体:
来源:转载
供稿:网友
JS 正则 时间验证代码,需要的朋友可以参考下。
 
 
复制代码代码如下:

function CheckTime() 

var checkValue = new RegExp ("^/[0-2]{1}/[0-6]{1}:/[0-5]{1}/[0-9]{1}:/[0-5]{1}/[0-9]{1}") ; 
var stControl = document.getElementById("txtStartTime") ; 
var stValue = stControl.value ; 
if (stValue == "") 

alert("请填写开始时间") ; 
return false ; 

if (!(checkValue.test(stValue))) 

alert("请填写公司内部规定时间") ; 
return false ; 

var etControl = document.getElementById("txtEndTime") ; 
var etValue = etControl.value ; 
if (etValue == "") 

alert("请填写结束时间") ; 
return false ; 

if (!(checkValue.test(etValue))) 

alert("请填写公司内部规定时间") ; 
return false ; 

return true ; 
}

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表