日期:2014-05-17 浏览次数:20905 次
<!DOCTYPE HTML> <html> <head> <meta charset="gb2312" /> <title></title> </head> <body> <input id="test" /> <button id="btn">提交</button> <script> function $(el){ return typeof el == 'string' ? document.getElementById(el) : el; } var re = /^[\.。]+$/; var t = $('test'); $('btn').onclick = function(){ if( !re.test(t.value) ){ alert('请输入....') }else{ alert('正确') } } </script> </body> </html>
------解决方案--------------------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <% Function IsValid(str) Dim regEx Set regEx = New RegExp regEx.Pattern = "^[.|。]+$" IsValid = regEx.Test(str) End Function Dim strTest strTest = "..。" '不通过 strTest="嘿嘿.." '通过 If IsValid(strTest) Then Response.Write("<meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8"" />") Response.Write "<script language=JavaScript>"& chr(13) &"alert('老大回复点有意思的!')</script>" Response.Write "<meta http-equiv=""refresh"" content=""0;url=test.asp""/>" End If %>