62,046
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<style>
</style>
<script>
function check(XelementId)
{
var text=document.getElementById(XelementId);
var reg=/^([0,1]\d|2[0-3]):[0-5]\d$/;
if(reg.test(text.value))
alert("验证通过");
else
alert("不通过");
}
</script>
</head>
<body>
<input type="text" id="text1"/>
<input type="button" value="验证" onclick="check('text1')"/>
</body>
</html>