An illegal character expression that determines the user name when registering

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.