asp ajax注册验证之 防止用户名输入空格(2)
fString=ReplaceText(fString,"([])([a-z0-9]*);","$1$2;")
fString=ReplaceText(fString,"(fuck|shit)",string(len("&$1&"),"*"))
if IsSqlDataBase=0 then '过滤片假名(日文字符)[\u30A0-\u30FF] by yuzi
fString=escape(fString)
fString=ReplaceText(fString,"%u30([A-F][0-F])","0$1;")
fString=unescape(fString)
end if
HTMLEncode=fString
End Function
''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''
Function RequestInt(fString)
RequestInt=Request(fString)
if IsNumeric(RequestInt) then
RequestInt=int(RequestInt)
else
RequestInt=0
end if
End Function
''''''''''''''''''''''''''''''''''''
UserName=HTMLEncode(unescape(Request.QueryString("UserName")))
UserNameLength=RequestInt("UserNameLength")
If len(UserName)<>UserNameLength Then
response.write "用户名非法!"
Else
response.write "用户名合法!"
End If
%>
HTMLEncode 函数是将用户名转换成合法字符的必须步骤。
RequestInt 函数主要根据输入有效字符的个数判断用户名是否包含空格。
调用方法:check.asp?UserName=用户名&UserNameLength=用户名长度
check.asp一般用于Ajax判断