JS Common phone number verification (linkage, mobile, telecommunications)

Source: Internet
Author: User

JS Common phone number verification (linkage, mobile, telecommunications)
Unicom number

function C_liantong (v) {
Return/^0? (?: 13[0-3]|15[1-35-6]|186) D{8}$/.test (v);
}

Mobile number

function C_yidong (v) {
Return/^0? (?: 13[4-9]|15[07-9]|18[789]) d{8}$/.test (v);
}

Phone number of Telecom

function C_dianxin (v) {
Return/^0? (?: 189) D{8}$/.test (v);
}

Note: Because the area code and phone number of the site are two areas, this function only verifies the phone number part
The area code is not. Because the area code may be less than 4 digits
Verify the landline number, which can be separated by several numbers--such as 028-12345678-123

function C_tel (v) {
var reg =/^ (?:d {4,8}-) *d{4,8}$/;
if (!) ( Reg.test (v)) return false;

var temp = v.split ('-');
if (temp.length>1) v = temp[1];
Reg =/^ (d) 1+$/;
var reg1 =/^1234 (?: 5|56|567|5678|56789)? $/;
Return! (Reg.test (v) | | Reg1.test (v));
}

Verify the mobile phone number is a mobile or unicom number

function C_mobile (v) {
return C_liantong (v) | | C_yidong (v) | | C_dianxin (v); Wanhua 20100226 Note this row
return/^d{11,16}$/.test (v);
}

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.

Tags Index: