Created
July 22, 2015 08:50
-
-
Save kokdemo/d1f6b3945a9cbb20ceb8 to your computer and use it in GitHub Desktop.
判断中国所有运营商的js
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
//判断手机号 | |
var mobilecheck = function(tel){ | |
var result = { | |
isMobile:false, | |
number:tel.toString(), | |
operator:'unknown' | |
}; | |
if(/^13[5-9]\d{8}$/g.test(tel) || | |
/^134[0-8]\d{7}$/g.test(tel) || | |
/^147\d{8}$/g.test(tel) || | |
/^15[0-27-9]\d{8}$/g.test(tel) || | |
/^178\d{8}$/g.test(tel) || | |
/^1705\d{7}$/g.test(tel) || | |
/^18[23478]\d{8}$/g.test(tel)){ | |
result.isMobile = true; | |
result.operator = 'ChinaMobile'; | |
} | |
else if(/^13[0-2]\d{8}$/g.test(tel) || | |
/^145\d{8}$/g.test(tel) || | |
/^15[56]\d{8}$/g.test(tel) || | |
/^176\d{8}$/g.test(tel) || | |
/^1709\d{7}$/g.test(tel) || | |
/^18[56]\d{8}$/g.test(tel)){ | |
result.isMobile = true; | |
result.operator = 'ChinaUnicom'; | |
} | |
else if(/^133\d{8}$/g.test(tel) || | |
/^153\d{8}$/g.test(tel) || | |
/^177\d{8}$/g.test(tel) || | |
/^1700\d{7}$/g.test(tel) || | |
/^18[019]\d{8}$/g.test(tel)){ | |
result.isMobile = true; | |
result.operator = 'ChinaTelecom'; | |
} | |
return result; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment