Implementation of js and php email address verification

Source: Internet
Author: User
Tags php email

There are many ways to verify the email address. On the Browser Side, js mailbox verification can be detected through regular expressions.

For example:
Copy codeThe Code is as follows:
Function isEmail (email ){
Return/^ ([a-z] | \ d | [! # \ $ % & '\ * \ + \-\/= \? \ ^ _ '{\|}~] | [\ U00A0-\ uD7FF \ uF900-\ uFDCF \ uFDF0-\ uFFEF]) + (\. ([a-z] | \ d | [! # \ $ % & '\ * \ + \-\/= \? \ ^ _ '{\|}~] | [\ U00A0-\ uD7FF \ uF900-\ uFDCF \ uFDF0-\ uFFEF]) +) * | (\ x22) (\ x20 | \ x09) * (\ x0d \ x0a ))? (\ X20 | \ x09) + )? ([\ X01-\ x08 \ x0b \ x0c \ x0e-\ x1f \ x7f] | \ x21 | [\ x23-\ x5b] | [\ x5d-\ x7e] | [\ u00A0-\ uD7FF \ uF900-\ uFDCF \ uFDF0-\ uFFEF]) | (\ ([\ x01-\ x09 \ x0b \ x0c \ x0d-\ x7f] | [\ u00A0-\ uD7FF \ uF900-\ uFDCF \ uFDF0-\ uFFEF]) ))) * (\ x20 | \ x09) * (\ x0d \ x0a ))? (\ X20 | \ x09) + )? (\ X22) @ ([a-z] | \ d | [\ u00A0-\ uD7FF \ uF900-\ uFDCF \ uFDF0-\ uFFEF]) | ([a-z] | \ d | [\ u00A0-\ uD7FF \ uF900-\ uFDCF \ uFDF0-\ uFFEF]) ([a-z] | \ d |-| \. | _ | ~ | [\ U00A0-\ uD7FF \ uF900-\ uFDCF \ uFDF0-\ uFFEF]) * ([a-z] | \ d | [\ u00A0-\ uD7FF \ uF900-\ uFDCF \ uFDF0-\ uFFEF]) \.) + ([a-z] | [\ u00A0-\ uD7FF \ uF900-\ uFDCF \ uFDF0-\ uFFEF]) | ([a-z] | [\ u00A0-\ uD7FF \ uF900-\ uFDCF \ uFDF0-\ uFFEF]) ([a-z] | \ d |-| \. | _ | ~ | [\ U00A0-\ uD7FF \ uF900-\ uFDCF \ uFDF0-\ uFFEF]) * ([a-z] | [\ u00A0-\ uD7FF \ uF900-\ uFDCF \ uFDF0-\ uFFEF]) $/I. test (email );
}

The call is simple:

Copy codeThe Code is as follows:
If (isEmail ('youremail @ yourdomain.com ') {console. log ('this is email is valid ');}

For server-side verification. Php is the simplest:

Copy codeThe Code is as follows:
/*
* Email Address validity Verification
*/

Function isEmail ($ mail_address ){
Return filter_var ($ mail_address, FILTER_VALIDATE_EMAIL );
}

But this can also be complicated.

Like this one. He established a complete email address verification website system. It is estimated that few people do this.

To be honest, I have to admire it.

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.