'正则表表达式验证函数 patrn-正则表达式 strng-需要验证的字符串
Function RegExpTest(patrn, strng)
Dim regEx, retVal ' 建立变量。
Set regEx = New RegExp ' 建立正则表达式。
regEx.Pattern = patrn ' 设置模式。
regEx.IgnoreCase = False ' 设置是否区分大小写。
retVal = regEx.Test(strng) ' 执行搜索测试。
RegExpTest = retVal '返回不尔值,不符合就返回false,符合为true
End Function
UserName=trim(unescape(request("UserName")))
if RegExpTest("^[@./-_A-Za-z0-9/u4E00-/u9FA5]{4,20}$",UserName)=false then
response.write "<run-script>alert('用户帐号由4-20个英文字母或数字、中文、字符@.-_等组成!');$('UserName').focus();</run-script>"
response.end
else
sql="select * from dv_user where username='"&UserName&"'"
set rs=conn.execute(sql)
if not rs.eof then
Response.write "<run-script>alert('该帐号已经存在!');$('UserName').focus();</run-script>"
response.end
end if
set rs=nothing
end if
nickname=trim(unescape(request("nickname")))
if RegExpTest("^[A-Za-z0-9/u4E00-/u9FA5]{1,20}$",nickname)=false then
Response.write "<run-script>alert('昵称必须是1-20位的中英文组成!');$('nickname').focus();</run-script>"
response.end
end if
UserPassword=trim(unescape(request("UserPassword")))
if RegExpTest("^[A-Za-z0-9]{4,20}$",UserPassword)=false then
Response.write "<run-script>alert('密码由4-20个英文字母或数字组成!');$('UserPassword').focus();</run-script>"
response.end
end if
UserPassword1=trim(unescape(request("UserPassword1")))
if UserPassword<>UserPassword1 then
Response.write "<run-script>alert('您两次输入的密码不一致,请确认!');$('UserPassword1').focus();</run-script>"
response.end
end if
UserEmail=trim(unescape(request("UserEmail")))
if RegExpTest("^([a-z0-9]*[-_]?[a-z0-9]+)*@([a-z0-9]*[-_]?[a-z0-9]+)+[/.][a-z]{2,3}([/.][a-z]{2})?$",UserEmail)=false then
Response.write "<run-script>alert('Email地址格式不正确!');$('UserEmail').focus();</run-script>"
response.end
end if
getcode=trim(unescape(request("getcode")))
if getcode<>Trim(Session("getCode")) then
Response.write "<run-script>alert('验证码错误!');$('getcode').focus();</run-script>"
response.end
end if
session.contents.remove("getCode")