jquery Verify mailbox and phone number is correct example

Source: Internet
Author: User
The code is as follows Copy Code

To achieve the source code:


<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>

<script type= "Text/javascript" src= "/public/js/jquery.min.js" ></script>

<script type= "Text/javascript" >

$ (function () {

$ ("#ck_mobile"). Click (function () {

var mobile = $ ("#mobile"). Val ();

if (!check_mobile (mobile)) {

Alert ("Mobile phone number format is not correct http://www.111cn.net");

}else{

Alert ("Mobile phone number is correct");

}

});

$ ("#ck_email"). Click (function () {

var email = $ ("#email"). Val ();

if (!check_email (email)) {

Alert ("Incorrect email format");

}else{

Alert ("email correct");

}

});

})


Check your phone number.

function Check_mobile (MOBILE) {

if (mobile.length!= | | | isNaN (MOBILE)) {

return false;

}

Mobile = Mobile.substr (0,3);

Number paragraph

var HD = new Array (' 130 ', ' 131 ', ' 132 ', ' 133 ', ' 134 ', ' 135 ', ' 136 ', ' 137 ', ' 138 ', ' 139 ', ' 150 ', ' 151 ', ' 152 ', ' 153 ', ' 154 ', ' 155 ' , ' 156 ', ' 157 ', ' 158 ', ' 159 ', ' 180 ', ' 181 ', ' 182 ', ' 183 ', ' 184 ', ' 185 ', ' 186 ', ' 187 ', ' 188 ', ' 189 ';

var i = hd.length;

while (i--) {

if (hd[i] = = Mobile) {

return true;

}

}

return false;

}


Verify that the mailbox is correct

function Check_email (email) {

var reg =/^ ([a-za-z0-9]+[_|_|.]?) *[a-za-z0-9]+@ ([a-za-z0-9]+[_|_|.]?) *[a-za-z0-9]+. [A-za-z] {2,3}$/;

if (!reg.test (email)) {

return false;

}else{

return true;

}

}

</script>


<p> Mobile Number: <input type= "text" id= "mobile"/> <input type= "button" value= "Verify mobile Number" id= "Ck_mobile"/></p >

<p>email:<input type= "text" id= "email"/> <input type= "button" value= "Verify mailbox Format" id= "Ck_email"/></p >

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.