日期:2014-05-17  浏览次数:20855 次

请教如何让某些用户在论坛留言中不打其它字,仅打一长串的省略号(个数不限)能给出一个警告提示呢?谢谢!
请教如何让某些用户在论坛留言中不打其它字,仅打一长串的省略号(个数不限)能给出一个警告提示呢?谢谢!


------解决方案--------------------
HTML code

<!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>

------解决方案--------------------
VBScript code

<%@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
%>