函數|會員
禁止垃圾註冊的方法
Public Function CheckNum(Str)
If Str="" Then Exit Function
If Session(Str)=False Then
RanDomize Timer
Session(Str)=Int(Rnd*9)+1
End If
CheckNum=Session(Str)
End Function
Function ValidInteger(str)
If Str="" then Exit Function
Dim re,chkstr
Set re=new RegExp
re.IgnoreCase =true
re.Global=True
re.Pattern="[^_\.0-9\d]"
ValidInteger=True
chkstr=re.Replace(Str,"")
ValidInteger=IsInteger(chkstr)
End Function
Public Function IsInteger(Para)
If Para="" then Exit Function
IsInteger=False
If Not (IsNull(Para) Or Trim(Para)="" Or Not IsNumeric(Para)) Then IsInteger=Para
'IsInteger=True
'End If
End Function
驗證
inspect=ValidInteger(Request.Form("inspect"))
If inspect<>Trim(CheckNum("n1")+CheckNum("n2")) or (Isempty(CheckNum("n1")))then
Response.Write "<script>alert('您輸入的註冊驗證有誤,使用半形IME輸入兩個數的和');history.back();</script>"
response.End()
end if
Session("n1")=False:Session("n2")=False'消除驗證碼
顯示頁面
<%=CheckNum("n1")&"+"&CheckNum("n2")%>= <input name="inspect" type="text" size="2" maxlength="2" />