An illegal character expression that determines the user name when registering
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_ Chinese _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_ Chinese _abc"))
</script>
User name requirement is to allow arbitrary Chinese, English, digital, underline combination
I don't seem to be very good at the moment, in which Chinese can't be registered. How to write an expression. Master give me the answer.
Front desk JS:
Tchk =/^[^ s~!@#$%^&* () _+|-=/?:; ' " [{]} ' .>,<]+$/;
if (!tchk.exec) (the. Username.value)) {
Alert ("Please enter the correct username!") ");
The. Username.focus ();
return false;
}
Background 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