Regular Expression common Verification

Source: Internet
Author: User
The input format needs to be verified in many places on the front-end. In order to facilitate future use, put the commonly used sorting here for future use. They are all tested and can be used with ease. I tried only two of them because I had something to do today. So here we should first put two. After the test is complete, we will add them up. Haha .... SyntaxHighlighter. all ();

The input format needs to be verified in many places on the front-end. In order to facilitate future use, put the commonly used sorting here for future use. They are all tested and can be used with ease. I tried only two of them because I had something to do today. So here we should first put two. After the test is complete, we will add them up. Haha. By the way, if you find a problem, we hope to raise it and make common progress.
 
Js Code
/**
Authentication username, which must consist of letters, numbers, and underscores (_), with 6 to 20 characters
*/
Function validateName (name ){

Var reg =/^ [\ w _] {6, 20} $ /;
If (reg. test (name )){
Return true;
}
Return false;
}
/**
Verify email
*/
Function validateEmail (email ){

Var reg =/^ [\ w _ \.] + @ [\ w] + \. [\ w] + $ /;
If (reg. test (email )){
Return true;
}
Return false;
}
I hope you can correct it.

 

This article is from "Junior programmers"
 

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.