<script language="javascript"><!-- /* // Regex Example in JavaScript // Rainsome Studio // 2009-07-16 in Shanghai //测试八位数字是否为有效日期 */function fun1() { var str1=document.getElementById("str1").value; var str2=document.getElementById("str2").value; var regex1 = new RegExp(str2,'g'); return regex1.test(str1); } function fun2(){alert(fun1());} // --></script>