Project requirements:
Enter the phone number, real-time judge the phone number entered the compliance with the rules:
If not, the Submit button is disabled, the mobile phone number information is not submitted, and the button displays a gray background;
If the rule is met, you can submit the phone number information you entered and set the button background to red.
The code is as follows:
Effect:
User input phone number is irregular:
When the user enters the phone number that matches the rule:
Ps:jquery Authentication Phone Number
var ismobile=/^ (?: 13\d|15\d|18\d) \d{5} (\d{3}|\*{3}) $/; Mobile phone number validation rule
var isphone=/^ ((0\d{2,3})-)? ( \d{7,8}) (-(\d{3,}))? $/; Landline validation Rule
var Dianhua = $ ("#dianhua"). Val (); Get the number value assigned by the user to the variable Dianhua
if (! Ismobile.test (Dianhua) &&!isphone.test (Dianhua) {//If the user enters a value that does not meet both the phone number and the landline number
("Please fill in the phone number correctly, for example : 13415764179 or 0321-4816048 "); Pop-up message
$ ("#dianhua"). focus (); The input box gets the cursor return
false; Returns an error, not executing down