Home > Backend Development > PHP Tutorial > How to implement email address verification in js and php_PHP tutorial

How to implement email address verification in js and php_PHP tutorial

WBOY
Release: 2016-07-13 10:41:57
Original
1028 people have browsed it

There are many ways to verify email addresses. On the browser side, js email verification can be detected through regular expressions.

For example:

Copy code The code is as follows:

function isEmail(email) {
return /^( (([a-z]|d|[!#$%&'*+-/=?^_`{|}~]|[u00A0-uD7FFuF900-uFDCFuFDF0-uFFEF])+(.([a-z]|d| [!#$%&'*+-/=?^_`{|}~]|[u00A0-uD7FFuF900-uFDCFuFDF0-uFFEF])+)*)|((x22)((((x20|x09)* (x0dx0a))?(x20|x09)+)?(([x01-x08x0bx0cx0e-x1fx7f]|x21|[x23-x5b]|[x5d-x7e]|[u00A0-uD7FFuF900-uFDCFuFDF0-uFFEF])|(\ ([x01-x09x0bx0cx0d-x7f]|[u00A0-uD7FFuF900-uFDCFuFDF0-uFFEF])))*(((x20|x09)*(x0dx0a))?(x20|x09)+)?(x22)))@ ((([a-z]|d|[u00A0-uD7FFuF900-uFDCFuFDF0-uFFEF])|(([a-z]|d|[u00A0-uD7FFuF900-uFDCFuFDF0-uFFEF])([a-z]|d|-|.|_ |~|[u00A0-uD7FFuF900-uFDCFuFDF0-uFFEF])*([a-z]|d|[u00A0-uD7FFuF900-uFDCFuFDF0-uFFEF]))).)+(([a-z]|[u00A0-uD7FFuF900-uFDCFuFDF0-uFFEF ])|(([a-z]|[u00A0-uD7FFuF900-uFDCFuFDF0-uFFEF])([a-z]|d|-|.|_|~|[u00A0-uD7FFuF900-uFDCFuFDF0-uFFEF])*([a-z]| [u00A0-uD7FFuF900-uFDCFuFDF0-uFFEF])))$/i.test(email);
}

The call is very simple:

Copy code The code is as follows:

if (isEmail('youremail@yourdomain.com')){ console.log( 'This is email is valid'); }

If it is server-side verification. Like php, the simplest one is:

Copy code The code is as follows:

/*
* Email address legality verification
*/

function isEmail($mail_address) {
return filter_var($mail_address, FILTER_VALIDATE_EMAIL);
}

But this matter can also be complicated.

Like this one. He established a complete system of email address verification websites. I guess few people do this.

To be honest, I have to admire it.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/676860.htmlTechArticleThere are many ways to verify email addresses. On the browser side, js email verification can be detected through regular expressions. For example: Copy the code The code is as follows: function isEmail(email) { return /^((([a...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template