How to determine the mobile phone number operator by js, And the js mobile phone number Operator

Source: Internet
Author: User

How to determine the mobile phone number operator by js, And the js mobile phone number Operator

This article describes how to determine the mobile phone number operator in js. Share it with you for your reference. The details are as follows:

For WEB projects, you may need to determine the operator of the mobile phone number based on the user's input, and then handle the number based on the operator, the following describes how to determine the operator code of a mobile phone number in js.
Js implementation method:

Var isChinaMobile =/^ 134 [0-8] \ d {7 }$ | ^ (?: 13 [5-9] | 147 | 15 [0-27-9] | 178 | 18 [2-478]) \ d {8} $ /; // mobile's latest response var isChinaUnion =/^ (?: 13 [0-2] | 145 | 15 [56] | 176 | 18 [56]) \ d {8} $ /; // confirm with Unicom Weibo that no response is made to var isChinaTelcom =/^ (?: 133 | 153 | 177 | 18 [019]) \ d {8 }$/; // no reply was given to China Telecom in section 1349, var isOtherTelphone =/^ 170 ([059]) \ d {7} $/; // var utils = {checkMobile: function (telphone) of other carriers) {telphone = this. trim (telphone); if (telphone. length! = 11) {return this. setReturnJson (false, 'no correct phone number' is detected ');} else {if (isChinaMobile. test (telphone) {return this. setReturnJson (true, 'mobile', {name: 'chinamobile '});} else if (isChinaUnion. test (telphone) {return this. setReturnJson (true, 'connection', {name: 'chinaunion '});} else if (isChinaTelcom. test (telphone) {return this. setReturnJson (true, 'telecom ', {name: 'chinatelcom'});} else if (isOtherTelphone. test (telph One) {var num = isOtherTelphone.exe c (telphone); return this. setReturnJson (true, '', {name:''});} else {return this. setReturnJson (false, 'no detected mobile phone number') ;}}, setReturnJson: function (status, msg, data) {if (typeof status! = 'Boolean' & typeof status! = 'Number') {status = false;} if (typeof msg! = 'String') {msg = '';} return {'status': status, 'msg ': msg, 'data': data };}}

I hope this article will help you design javascript programs.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.