JS mobile phone number and phone number verify regular expressions

Source: Internet
Author: User

/********************
Function Name: Istelephone
function function: fixed, mobile phone number check function, return True, reverse, return false
function parameters: obj, number to be checked
Check rule:
(1) Number, "(", ")" and "-"
(2) The phone number is 3 to 8 digits
(3) If the phone number contains an area code, then the area code is three-bit or four-bit
(4) The area code is separated by "(", ")" or "-" and other parts
(5) The mobile phone number is 11 or 12 bits, if 12 bits, then the first digit is 0
(6) The first and second digits of the 11-digit mobile phone number are "13"
(7) The second and third digits of the 12-digit mobile phone number are "13"
********************/
function Istelephone (obj) {//Regular judgment
var pattern=/(^[0-9]{3,4}\-[0-9]{3,8}$) | (^[0-9]{3,8}$) | (^\ ([0-9]{3,4}\) [0-9]{3,8}$] | (^0{0,1}13[0-9]{9}$) | (^0{0,1}14[0-9]{9}$) | (^0{0,1}15[0-9]{9}$) | (^0{0,1}17[0-9]{9}$) | (^0{0,1}18[0-9]{9}$)/;
if (pattern.test (obj)) {
return true;
}else{
return false;
}

}

JS mobile phone number and phone number verify regular expressions

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.