Example of jquery+ Regular expression validation mailbox format

Source: Internet
Author: User

Js:

$ ("#email"). blur (function () {//Gets the value of the element corresponding to the ID, minus its left and right space var email = $.trim ($ (' #email '). Val ());//Verify the mailbox format of the JS regular expression var Isemail =/^\w+ ([-+.] \w+) *@\w+ ([-.] \w+) *\.\w+ ([-.] \w+) *$/; Empties the data in the display layer by     $ ("#emailMess"). HTML (""); if (email = = "") {   $ ("#emailMess"). HTML ("<font color= ' Red ' >" + "Mailbox cannot be empty" + "</font>");} else if (!) ( Isemail.test (email)) {   $ ("#emailMess"). HTML ("<font color= ' Red ' >" + "Mailbox format is incorrect" + "</font>");} else{                   //Here you can send JSON data to the background and return the validation result        }

HTML:

<script type= "Text/javascript" src= "js/jquery-1.10.1.js" ></script><div class= "li" >    < Label for= "Email" class= "label" ><span class= "Flag" >* </span> mailbox:</label> <input type=    " Text "Name=" Userinfo.email "id=" email "placeholder=" Please enter a valid mailbox "size=" "maxlength="/><label id= "emailmess" class= "Label_mess" ></label></div>


Example of jquery+ Regular expression validation mailbox format

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.