Created
July 5, 2014 07:08
-
-
Save hehongwei44/2bbfbb5d6dccea3b2285 to your computer and use it in GitHub Desktop.
判断输入的参数是否是个合格的手机号码
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * | |
| * @descrition:判断输入的参数是否是个合格的手机号码,不能判断号码的有效性,有效性可以通过运营商确定。 | |
| * @param:str ->待判断的手机号码 | |
| * @return: true表示合格输入参数 | |
| * | |
| */ | |
| var isCellphone = function(str) { | |
| /** | |
| *@descrition:手机号码段规则 | |
| * 13段:130、131、132、133、134、135、136、137、138、139 | |
| * 14段:145、147 | |
| * 15段:150、151、152、153、155、156、157、158、159 | |
| * 17段:170、176、177、178 | |
| * 18段:180、181、182、183、184、185、186、187、188、189 | |
| * | |
| */ | |
| var pattern = /^(13[0-9]|14[57]|15[012356789]|17[0678]|18[0-9])\d{8}$/; | |
| return pattern.test(str); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment