Created
September 26, 2014 11:20
-
-
Save rockstar2046/5532341e8faddd43cc00 to your computer and use it in GitHub Desktop.
Assert phone number type (for china)
This file contains 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
/** | |
* Return phone number type | |
* <p>For china:</p> | |
* <ul> | |
* <li>0 unknow</li> | |
* <li>1 china mobile (cellphone)</li> | |
* <li>2 china unicom (cellphone)</li> | |
* <li>3 china net (cellphone)</li> | |
* <li>4 china net (telphone)</li> | |
* </ul> | |
* @return {Number} number type | |
*/ | |
String.prototype.pnt=function(){ | |
var __cm = /^(((13[5-9])|(147)|(15[012789])|(18[23478]))\d{8})|(134[0-8])\d{7}$/; | |
var __cu = /^((13[0-2])|(145)|(15[5-6])|(18[5-6]))\d{8}$/; | |
var __ct = /^(((133)|(153)|(18[019]))\d{8})|(1349)\d{7}$/; | |
var __tel= /^((0[12]\d{1}\d{8})|(0[3-9]\d{2}\d{7,8}))$/; | |
var __retval= | |
__cm.test(this) ? 1: | |
__cu.test(this) ? 2: | |
__ct.test(this) ? 3: | |
__tel.test(this) ? 4: | |
0; | |
return __retval; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment