How to verify the correct mobile phone number and email format by using jquery? jquery-js tutorial

Source: Internet
Author: User
This article describes how to use jquery to verify your email address and mobile phone number. The specific implementation ideas and Code are as follows: The Code is as follows:


// Jquery verification email
Function checkSubmitEmail (){
If ($ ("# email"). val () = ""){
// $ ("# ConfirmMsg" pai.html ("the email address cannot be blank! ");
Alert ("email cannot be blank! ")
$ ("# Email"). focus ();
Return false;
}
If (! $ ("# Email "). val (). match (/^ \ w + (-\ w +) | (\. \ w +) * \ @ [A-Za-z0-9] + ((\. |-) [A-Za-z0-9] + )*\. [A-Za-z0-9] + $ /)){
Alert ("Incorrect email format ");
// $ ("# ConfirmMsg" ).html ("Incorrect email format! Enter again! ");
$ ("# Email"). focus ();
Return false;
}
Return true;
}

// Jquery verifies the mobile phone number
Function checkSubmitMobil (){
If ($ ("# mobile"). val () = ""){
Alert ("the mobile phone number cannot be blank! ");
// $ ("# MoileMsg" developer.html ("the mobile phone number cannot be blank! ");
$ ("# Mobile"). focus ();
Return false;
}

If (! $ ("# Mobile "). val (). match (/^ (13 [0-9] {1}) | 159 | 153) + \ d {8}) $ /)){
Alert ("Incorrect mobile phone number format! ");
// $ ("# MoileMsg" ).html ("Incorrect mobile phone number format! Enter again! ");
$ ("# Mobile"). focus ();
Return false;
}
Return true;
}

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.