生成随机字符串的函数,加上cookies或者session就可以当验证码用了。
LengthNum,字符长度,就是生成随机字符串的长度
演示 1:<%=GetRndStr(9)%><br />
演示 2:<%=GetRndStr("9")%><br />
<%
Function GetRndStr(LengthNum)
If isDebug Then On Error Resume Next End If
Dim Ran,i
GetRndStr=""
For i=1 To Abs(LengthNum)
Randomize
Ran = CInt(Rnd * 2)
Randomize
If Ran = 0 Then
Ran = CInt(Rnd * 25) + 97
GetRndStr =GetRndStr& UCase(Chr(Ran))
ElseIf Ran = 1 Then
Ran = CInt(Rnd * 9)
GetRndStr = GetRndStr & Ran
ElseIf Ran = 2 Then
Ran = CInt(Rnd * 25) + 97
GetRndStr =GetRndStr& Chr(Ran)
End If
Next
End Function
%>