Javascript verification mobile phone number

Source: Internet
Author: User

Regular Expression ^ 1 [3 | 4 | 5 | 8] [0-9] \ D {4, 8} $

^ 1 indicates a Chinese mobile phone number starting with 1.
[3 | 4 | 5 | 8] After 1, it can be a number of 3, 4, 5, or 8. If the phone number starting with 190 is displayed, the following is required: [3 | 4 | 5 | 8 | 9]
[0-9] indicates any number in the middle of 0-9, which can be 0 or 9.
The \ D {} is the same as that of [0-9]. It is a number in the middle of 0-9. {4, 8} indicates matching the first four digits with a maximum of eight digits. Why is it not the 8-bit mobile phone number, because the first seven digits can be used to know the specific address when the phone number is retrieved from the location, and the last four digits will not be affected.

 

<SCRIPT type = "text/JavaScript">
Function checkmobile (){
VaR smobile = Document. mobileform. Mobile. Value
If (! (/^ 1 [3 | 5 | 8] [0-9] \ D {4, 8} $/. Test (smobile ))){
Alert ("the first seven digits of a complete 11-digit mobile phone number or a correct mobile phone number ");
Document. mobileform. Mobile. Focus ();
Return false;
}
}
</SCRIPT>

<Form action = "http://ip.jb51.net/sj/mobile2.asp" name = "mobileform" method = "Post" onsubmit = "Return checkmobile ();">
<Input name = "mobile" class = TDC size = "40" maxlength = "11">
<Input name = "action" type = "hidden" value = Mobile> <input class = bdtj name = b1 type = submit value = "">
</Form>

 

Related Article

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.