html5中文学习网

您的位置: 首页 > 网络编程 > 正则表达式 » 正文

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 ;
}
(责任编辑:)
推荐书籍
推荐资讯
关于HTML5先行者 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 人才招聘 - 帮助