<script language="javascript">
<!--
function checkform(){
re=/^\d{2}:\d{2}$/;
if(re.test(form1.digit.value)){
alert("right!");
}else {
alert("wrong!");
}
return false;
}
//-->
</script>
<form name="form1" method="post" action="" onsubmit="return checkform()">
<input name="digit" type="text" id="digit">
<input type="submit" name="Submit" value="提交">
</form>
<!--
function checkform(){
re=/^\d{2}:\d{2}$/;
if(re.test(form1.digit.value)){
alert("right!");
}else {
alert("wrong!");
}
return false;
}
//-->
</script>
<form name="form1" method="post" action="" onsubmit="return checkform()">
<input name="digit" type="text" id="digit">
<input type="submit" name="Submit" value="提交">
</form>
将上面的正则式用于代码中即可