74007124
Recently in the registration landing page, are involved in verifying 11 valid mobile phone numbers, posted here code, hoping to help the development needs of friends.
[JavaScript]View PlainCopy
- function Isponeavailable ($poneInput) {
- var myreg=/^[1][3,4,5,7,8][0-9]{9}$/;
- if (!myreg.test ($poneInput. Val ())) {
- return false;
- } Else {
- return true;
- }
- }
Here I directly encapsulated in a method, need to use the time to pass in a JQ object of input. Of course, you can also pass in strings directly, such as:
[JavaScript]View PlainCopy
- function Isponeavailable (str) {
- var myreg=/^[1][3,4,5,7,8][0-9]{9}$/;
- if (!myreg.test (str)) {
- return false;
- } Else {
- return true;
- }
- }
The emphasis here is on this regular expression:
[JavaScript]View PlainCopy
- var myreg=/^[1][3,4,5,7,8][0-9]{9}$/;
The meaning of this expression is:
The beginning of the 1;
2--the second place may be 3,4,5,7,8, any one in;
3--ends with 9 integers of 0-9.
Originally only allow 13,15,17,18, the beginning of the mobile phone number, but the test mm said there are 14 beginning of the number, so added 14; Of course, if later developed into a 16, or 19, such as the opening number,
[JavaScript]View PlainCopy
- [3,4,5,7,8]
can be added.
Pro-Test feasible 20180428
2017-9-8
[JavaScript]View PlainCopy
- Determine if the phone number is
- Isponeavailable: function (pone) {
- var myreg =/^[1][3,4,5,7,8][0-9]{9}$/;
- if (!myreg.test (pone)) {
- return false;
- } Else {
- return true;
- }
- },
- //Determine if it is a phone number
- Istelavailable: Function (tel) {
- var myreg =/^ (([0\+]\d{2,3}-)? ( 0\d{2,3})-) (\d{7,8}) (-(\d{3,}))? $/;
- if (!myreg.test (tel)) {
- return false;
- } Else {
- return true;
- }
- },
JS Regular expression verifies whether it is a 11-bit valid mobile number,