-
<html>
-
<head>
-
<title>测试八位数字是否为有效日期</title>
-
</head>
-
<scriptlanguage="javascript"><!--functionfun1(){varstr1=document.getElementById("str1").value;varstr2=document.getElementById("str2").value;varregex1=newRegExp(str2,'g');returnregex1.test(str1);}functionfun2(){alert(fun1());}//--></script>
-
<body>
-
<div>
-
<span>String:</span><inputid="str1"type="text"value="19990228"size="100"/><span>Regex:</span><inputid="str2"type="text"value='^(?:(?:(?:(?=\d{2}(?:(?:[02468][048])|(?:[13579][26])))\d{4}02(?!00)[0-2]\d))|(?:\d{4}(?:(?:(?:(?:0[469])|(?:11))(?!00)(?:(?:[0-2]\d)|(?:30)))|(?:(?:(?:0[13578])|(?:1[02]))(?!00)(?:(?:[0-2]\d)|(?:3[01])))|(?:02(?!(?:00)|(?:29))[0-2]\d))))$'size="100"/><inputtype="button"value="OK"onclick="javascript:fun2();"/>
-
</div>
-
</body>
-
</html>
如果您对该产品感兴趣,请填写办理(客服微信:xiaoxiongyidong)
发表评论
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。