JS Judge mobile phone number

Source: Internet
Author: User


Phone number format: 0574-12345678,0574-12345678-2,12345678,0556-1234567,021-12345678
Fixed-line except for the following areas are 8, other areas of the city's ordinary civil numbers are 7
As of September 2009, a total of 19 provinces and municipalities in the number of 51 cities and towns have risen to 8 places

Beijing 010 Shanghai 021 Tianjin 022 Chongqing Municipality 023
Hebei Province: Shijiazhuang City 0311
Liaoning Province: Shenyang City 024 Dalian 0411
Jilin Province: Changchun City 0431 Jilin City 0432 (expected October 24, 2009 rise)
Heilongjiang: Harbin City 0451
Jiangsu Province: Nanjing 025 Wuxi 0510 Zhenjiang 0511 Suzhou 0512 Nantong City 0513
Yangzhou 0514 Yancheng 0515 Xuzhou 0516 Huaian 0517 Lianyungang 0518
Changzhou 0519 Taizhou 0523 Suqian 0527
Zhejiang Province: Hangzhou City 0571 Jiaxing 0573 Ningbo 0574 Shaoxing 0575 Taizhou 0576
Wenzhou 0577 Jinhua 0579
Fujian province: Fuzhou 0591 Quanzhou 0595
Shandong Province: Jinan City 0531 Qingdao 0532
Henan province: Zhengzhou 0371 Nanyang 0377 Luoyang 0379
Hubei Province: Wuhan 027
Hunan Province: Changsha 0731 (Xiangtan, Zhuzhou city)
Guangdong Province: Guangzhou 020 Shantou 0754 shenzhen 0755 Foshan 0757 Zhongshan City 0760
Dongguan 0769
Hainan Province: Haikou 0898 (Sanya)
Sichuan Province: Chengdu City 028 (Ziyang, Meishan before the end of the year)
Shaanxi Province: Xi ' an city 029 (Xianyang)

--------------------------------------------------------------------------------
Fixed telephone to judge JS related code
[/color]
function Checktel (tel) {
var reg=/^[\d|\-|\s|\_]+$/;
var isOk = reg.test (tel);
if (isOk && tel.indexof ("-") <0 &&! ( tel.length==7| | tel.length==8)) {
IsOk = IsOk && false;
}else if (isOk && tel.indexof ("-") >0) {
var Firsttel = tel.substring (Tel.indexof ("-"));
if (firsttel.length>1) {
Firsttel = firsttel.substring (1);
if (Firsttel.indexof ("-") <0) {
if (firsttel.length!=7 && firsttel.length!=8) {
IsOk = IsOk && false;
The phone length is not correct after alert ("area code"). ");
}
}else{
Firsttel = firsttel.substring (0,firsttel.indexof ("-"));
if (firsttel.length!=7 && firsttel.length!=8) {
IsOk = IsOk && false;
The phone length is not correct after alert ("area code"). ");
}
}
}else{
IsOk = IsOk && false;
The phone length is not correct after alert ("area code"). ");
}
}
return isOk;
};

--------------------------------------------------------------------------------


Cell phone number judgment, mobile phone format and related data collation and code


<script language= "JavaScript" >
<!--
function Checkmobile (oform) {
Cell Phone judgment
var Mob=oform.mob.value;
var reg0=/^13\d{5,9}$/; 130--139. At least 7 digits
var reg1=/^153\d{4,8}$/; Unicom 153. At least 7 digits
var reg2=/^159\d{4,8}$/; Move 159. At least 7 digits
var reg3=/^189\d{4,8}$/; Telecom
var reg3=/^158\d{4,8}$/;
var My=false;
if (Reg0.test (mob)) my=true;
if (Reg1.test (mob)) my=true;
if (Reg2.test (mob)) my=true;
if (Reg3.test (mob)) my=true;
if (Reg4.test (mob)) my=true;
if (!my) {
Oform.mob.value= ';
Alert (' Sorry, the phone number you entered is wrong. ');
Oform.mob.select ();
Oform.mob.focus ();
return to my;
}
End of cell phone judgment
-->
</script>

--------------------------------------------------------------------------------

JS regular expression to determine the fixed telephone, PHS, mobile phone number


<title>js Regular expressions to determine fixed-line, PHS, mobile phone number </title>
<body>
<script language= "javascript"
///matching fixed telephone or PHS, for example: 031185907468 or 02185907468 format
function The Isphone1 () {
var num = document.getElementById (' ph '). value;
var partten =/^0 ([1-9]\d) | ( [3-9]\d{2})) \d{8}$/;
if (partten.test (num)) {
Alert (' is phone number ');
} else{
Alert (' Not phone number ');

}
Function Isphone2 () {
var num = document.getElementById (' MB '). value;
var partten =/^1[3,5]\d{9}$/;
if (Partten.test (num)) {
Alert (' is a mobile number ');
else{
Alert (' Not mobile number ');

}
</script>
Please enter a fixed telephone or PHS number: <input type= "text" name= "phone" id= "ph" ><input type= "button" Value= "Test" onclick= "isphone1 ();"
Please enter your mobile number: <input type= "text" name= "phone" id= "MB" ><input type= "button" value= "Test" onclick= "Isphone2 () ;"
</body>

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.