<pre name= "Code" class= "JavaScript" >//verify your phone number or phone number functionCheckcontactnumber () {$ ("#error"). CSS ("display", "none"); varMobile = $.trim ($ ("#ContactNumber"). Val ()); varIsMobile =/^ ((13[0-9]{1}) | ( 15[0-9]{1}) | (18[0-9]{1}) | (17[0-9]{1}) | (14[0-9]{1})) +\D{8}) $/; varIsphone =/^ (?:(?: 0 \d{2,3})? (?:\ d{7,8}) (-(?: \ D{3,}))? $/;; varError = "<label id=\" error\ "class=\" validate_input_error\ "> Please fill in the correct phone number, for example: 13511111111 or 010-11111111</label > "; //Verify the phone number if you start with 1 if(mobile.substring (0, 1) = = 1) { if(!ismobile.exec (MOBILE) && mobile.length! = 11) { $("#ContactNumber"). After (error); $("#ContactNumber"). focus (); return false; } } //Verify the fixed phone number if you start with 0 Else if(mobile.substring (0, 1) = = 0) { if(!isphone.test (MOBILE)) { $("#ContactNumber"). After (error); $("#ContactNumber"). focus (); return false; } } //Otherwise, it won't all pass . Else { $("#ContactNumber"). After (error); $("#ContactNumber"). focus (); return false; } return true; }
jquery verified phone numbers and fixed phone numbers