【www.gdgbn.com--网页配色】
注册时判断用户名的非法字符表达式
Function IsValidStr(str)
Dim re
Set re = New RegExp
re.Pattern="^[u4e00-u9fa5a-z_][u4e00-u9fa5w]*$"
re.Global=True
IsValidStr= re.Test(str)
End Function
<script type="text/javascript">
function isBadStr(s){
return /[^wu4e00-u9fa5]/.test(s);
}
alert(isBadStr(""))
alert(isBadStr("123_中文_abc"))
</script>
<script type="text/vbscript">
Function isBadStr(str)
Dim re
Set re = New RegExp
re.Pattern="[^wu4e00-u9fa5]"
isBadStr= re.Test(str)
End Function
alert(isBadStr(""))
alert(isBadStr("123_中文_abc"))
</script>
用户名要求是 允许任意中文、英文、数字、下划线组合
我现在好像不怎么好,其中中文不能注册。要怎么写表达式。高手给我答案吧。
前台JS:
tChk = /^[^ s~!@#$%^&*()_+|-=/?:;""[{]}`.>,<]+$/;
if(!tChk.exec(the.UserName.value)){
alert("请输入正确的用户名!");
the.UserName.focus();
return false;
}
后台VBS:
Function IsValidStr(str)
IsValidStr=False
Dim RE
Set re = New RegExp
re.pattern="^[a-zA-Z0-9_]+$"
IsValidStr= Not re.Test(str)
End Function