最簡單的asp驗證碼
<%
Public Function BornVerifyCode()
Randomize ‘設置隨機因子
BornVerifyCode=Mid((Rnd * 1000000), 1, 4) ‘生成6位隨機數,取高4位
End Function
%>
調用:<%=BornVerifyCode%>
<%
Function CheckCode
const theNum = 4 ‘設置位數,修改就是了
‘*************************************************************
dim strCode,theCodes,str0
theCodes = "" ‘初始化驗證碼字符
strCode = "123456789AABCDEFGHI135GGW468HJKLMNTPQRS148963TUVWR"
strCode = LCASE(strCode) ‘全部換成小寫,當然也可不換
RANDOMIZE
for i = 1 to theNum
‘循環結構重復篩選單個字符進行組合,生成theNum位的驗證碼
str0=mid(strCode,INT((50-1+1)*RND+1),1)
‘str0為一次循環周期內經篩選的單個臨時字符
theCodes = theCodes&str0 ‘字符疊加過程
next
if theCodes = "" then
theCodes = "9999"
end if
Session("SystemRocCode") = cstr(theCodes)
‘將字符結果保存在Seesion中
Response.Write theCodes ‘顯示出驗證字符
End Function
%>
調用:<%=CheckCode%>
最簡單的asp驗證碼