今天看了好几个版本的注册系统,发现几乎都存在注册中文帐号的问题,虽然有的用“if asc(ps_loginname)<0 then”做了过滤,但是这样并不能防止帐号中含有中文,例如“aa中文bb”这样的帐号。于是做了些修正,希望对大家有用。
首先在注册程序里加入下面一段代码
<%
function strlen(str)
dim p_len
p_len=0
strlen=0
if trim(str)<>"" then
p_len=len(trim(str))
for xx=1 to p_len
if asc(mid(str,xx,1))<0 then
strlen=int(strlen) + 2
else
strlen=int(strlen) + 1
end if
next
end if
end function
%>
然后把“if asc(ps_loginname)<0 then ”改为
“if strlen(ps_loginname) <> len(ps_loginname) then”
就可以了。
如果原来没有中文过滤的就在适当位置加上
检查是否含有中文->
if strlen(ps_loginname) <> len(ps_loginname) then
response.write "<script language=javascript>alert(注意,用户名里不能含有中文!);history.back();</script>"
response.end
end if
还有另一个关于大小写帐号的问题:
把“ps_loginname=request.form("ps_loginname")”改为
“ps_loginname=LCase(request.form("ps_loginname"))”就可以了

sf78.com/down_info.asp?id=172" width=1 border=0 onload="return imgzoom(this,550);" onclick="javascript:window.open(this.src);" style="cursor: pointer;"/>