jquery Verification Mailbox Email Verification instance

Source: Internet
Author: User
Tags regular expression valid email address

Some time ago to deal with the verification of mobile phone, amount, decimal point and other verification. Recently done the page, and encountered a verification of the mailbox, the process is not much said, directly to see the code. Implementation key or regular, regular expression is very powerful. There is a chance to learn, but it is not easy to learn. Fortunately some of the commonly used, online can be found. But you know what you have to do!

The code is as follows Copy Code

$ (function () {

$ ("#email"). blur (function () {
var Txt_value = $ (this). Val ();
if (txt_value== "") {
$ (this). val ("Please enter your email address")
}else if (!) ( /^w+ ([.-]?w+) *@w+ ([.-]?w+) * (. w{2,3}) +$/.test (Txt_value))) {
Alert ("Please enter a valid email address");
$ (this). Val ("");
return false;
}

})

})

Inside the form the Mailbox text box name and id attribute are all email. Add Mouse to move out events.

Cases

The code is as follows Copy Code

Mailbox Verification
if ($ ("#email"). val () = ") {
$ ("#email"). focus ();
Alert ("Please fill in your mailbox");
return false;
}else{
var val = $ ("#email"). Val ();
if (Val.match/^[a-z0-9]+ ([. _]*[a-z0-9]+) *@[a-z0-9]+ ([_.] [a-z0-9]+) +$/gi))
{return true};
Alert ("Incorrect mailbox format, please fill in");
$ ("#email"). focus ();
return False
}

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.