日期:2014-05-16 浏览次数:20996 次
<input type="text" name="VerifyCode" maxlength="4" size="10" onBlur="CheckVerifyCode(this.value)" onKeyUp="if (this.value.length == 4)CheckVerifyCode(this.value)" onfocus="getVerifyCode()" /> <span id="VerifyCodeImgID">点击输入框获取验证码</span> <span id="CheckVerifyCode" style="color:red"></span>
/*显示验证码*/
function getVerifyCode() {
if(document.getElementById("VerifyCodeImgID"))
document.getElementById("VerifyCodeImgID").innerHTML = '<img src="VerifyCode.asp?t='+Math.random()+'" alt="点击刷新验证码" style="cursor:pointer;border:0;vertical-align:middle;" onclick="this.src=\'VerifyCode.asp?t=\'+Math.random()" />'
}
function CheckVerifyCode(VerifyCode) {
var patrn=/^\d+$/; //纯数字
if(!patrn.exec(VerifyCode)) {
ShowCheckResult("CheckVerifyCode", "您没有输入验证码或输入有误。","error");
return;
}
Ajax_CallBack(false,"CheckVerifyCode","Loading.asp?menu=CheckVerifyCode&VerifyCode=" + VerifyCode);
}
<%
Option Explicit ' 显示声明
Class Com_GifCode_Class
Public Noisy, Count, Width, Height, Angle, Offset, Border
Private Graph(), Margin(3)
Private Sub Class_Initialize()
Randomize
Noisy = 0 ' 干扰点出现的概率
Count = 4 ' 字符数量
Width = 60 ' 图片宽度
Height = 18 ' 图片高度
Angle = 0 ' 角度随机变化量
Offset = 0 ' 偏移随机变化量
Border = 2 ' 边框大小
End Sub
Public Function Create()
Const cCharSet = "123456789"
Dim i, x, y
Dim vValidCode : vValidCode = ""
Dim vIndex
ReDim Graph(Width-1, Height-1)
For i = 0 To Count - 1
vIndex = Int(Rnd * Len(cCharSet))
vValidCode = vValidCode + Mid(cCharSet, vIndex+1 , 1)
SetDraw vIndex, i
&