Verify that the account is valid
Verification rules: a combination of letters, numbers, and underscores. It must start with a letter and contain 4-16 characters.
FunctionCheckuser (STR ){VaRRe=/^ [A-Za-Z] \ W {3, 15} $/;If(Re. Test (STR) {alert ("Correct");}Else{Alert ("Error") ;}} Checkuser ("jiade_cnblogs");//Call
Verify mobile phone number
Verification rules: 11-digit number, starting with 1.
FunctionCheckmobile (STR ){VaRRe=/^ 1 \ D {10} $/If(Re. Test (STR) {alert ("Correct");}Else{Alert ("Error") ;}} Checkmobile ('123 ');//CallCheckmobile ('20140901 ');//Error example
Verify phone number
Verification rules: area code + number. The area code starts with 0 and has three or four digits.
The number consists of seven or eight digits.
There can be no connector or "-" connection between the area code and the number.
For example, 01088888888,010-888888,0955-7777777
FunctionCheckphone (STR ){VaRRe=/^ 0 \ D {2, 3 }-? \ D {7, 8} $/;If(Re. Test (STR) {alert ("Correct");}Else{Alert ("Error") ;}} Checkphone ("09557777777 ");//Call
Verify email
Verification rules: divide the email address into "first part @ second part ".
The first part is composed of letters, numbers, underscores, short-term "-", and period,
The second part is a domain name, which consists of letters, numbers, short-term "-", and domain name suffixes,
The domain name suffix is generally. xxx or. XXX. XX. The domain name suffix of a region is generally 2-4 characters, such as CN, COM, and net. Now some domain names will be larger than 4 characters
FunctionCheckemail (STR ){VaRRe=/^ (\ W-* \. *) + @ (\ W -?) + (\. \ W {2,}) + $/If(Re. Test (STR) {alert ("Correct");}Else{Alert ("Error") ;}} Checkemail ("Contact@cnblogs.com");//Call
Modified from: http://blog.csdn.net/bkq421511585/article/details/8027445