. 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.
?
Function
CheckUser (str ){
Var
Re =/^ [a-zA-z] \ w {3, 15} $ /;
If (re. test (str )){
Alert ("correct ");
} Else {
Alert ("error ");
}
}
CheckUser ("q_11"); // call
2. Verify the mobile phone number
Verification rules: 11-digit number, starting with 1.
Function
CheckMobile (str ){
Var
Re =/^ 1 \ d {10 }/
If (re. test (str )){
Alert ("correct ");
} Else {
Alert ("error ");
}
}
CheckMobile (13900001111); // call
3. Verify the 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, 01012345678 010-12345678.
Function
CheckPhone (str ){
Var
Re =/^ 0 \ d {2, 3 }-? \ D {7, 8} $ /;
If (re. test (str )){
Alert ("correct ");
} Else {
Alert ("error ");
}
}
CheckPhone ("012312345678"); // call
4. 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
Function
CheckEmail (str ){
Var
Re =/^ (\ w-* \. *) + @ (\ w -?) + (\. \ W {2,}) + $/
If (re. test (str )){
Alert ("correct ");
} Else {
Alert ("error ");
}
}
CheckEmail ("s_test@test.cn"); // call