Var isChinaMobile =/^ 134 [0-8] \ d {7 }$ | ^ (? : 13 [5-9] | 147 | 15 [0-27-9] | 178 | 18 [2-478]) \ d {8} $ /; // mobile latest reply Var isChinaUnion =/^ (? : 13 [0-2] | 145 | 15 [56] | 176 | 18 [56]) \ d {8} $/; // confirm with Unicom Weibo that no response has been made Var isChinaTelcom =/^ (? : 133 | 153 | 177 | 18 [019]) \ d {8} $/; // The telecommunications team of section 1349 did not provide a reply, which is deemed to be nonexistent Var isOtherTelphone =/^ 170 ([059]) \ d {7} $/; // other carriers Var utils = { CheckMobile: function (telphone ){ 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, 'telet', {name: 'chinatelcom '}); } Else if (isOtherTelphone. test (telphone )){ Var num = isOtherTelphone.exe c (telphone ); Return this. setReturnJson (true, '', {name :''}); } Else { Return this. setReturnJson (false, 'no correct phone number' is detected '); } } }, 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 }; } } |