JS verification phone number and mobile phone support +86 Regular expression

Source: Internet
Author: User
Tags regular expression

  This article mainly introduces the JS verification phone number and mobile phone support +86 regular expression. Need friends can come to the reference, I hope to help you.

The code is as follows: <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <html xmlns=" http://www.w3.org/1999/xhtml "> <head>     <title> Regular expression validation </title >       <script type= "Text/javascript" src= ". /scripts/jquery-1.4.1.min.js "></script>     <script type=" Text/javascript ">         var Validate = {              Istel:function (s) {                var patrn =/^ (+?86) | ( (+86))? d{3,4}-d{7,8} (-d{3,4})? $/                if (!patrn.exec (s)) return false                 return true            },     &N Bsp         Ismobile:function (value) {                var valid Atereg =/^ (+?86) | ((+86))? 1d{10}$/;                 return validatereg.test (value);            ,               cellphone:function () {&NB Sp               var cellphonenumber = $ ("#txtCellPhone"). Val ();                 if (! Validate.ismobile (CellPhoneNumber)) {                    alert ("Mobile number format not Correct ");                     return false;                } else {                & nbsp   Alert ("Your phone number is in the correct format");                 &nbsp            },     ;         telephone:function () {                var telephonenumber = $ ("#txttelePhone"). Val ();                 if (! Validate.istel (telephonenumber)) {                    alert ("Wrong phone number format" );                     return false;                } else {                & nbsp   Alert ("Your phone number format is correct");                            }        }     </script> </head> <body> <div>    <label> Please enter your mobile number (support +86): </label><input type= "text" id= "Txtcellphone"/><input  type= "button" value= "Verify" onclick= " Validate.cellphone (); " /><br/>     <label> Please enter the phone number (support +86): </label><input type= "text" id= "Txttelephone"/ ><input  type= "button" value= "Verify" onclick= "Validate.telephone" (); " /><br/> </div> </body> </html>  

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.