Home >Web Front-end >JS Tutorial >A way to write js email verification method

A way to write js email verification method

一个新手
一个新手Original
2017-09-09 10:23:561318browse

Verify Email

function check(){
var email=document.getElementById("email").value;
var isemail=/^[a-z]([a-z0-9]*[-_]?[a-z0-9]+)*@([a-z0-9]*[-_]?[a-z0-9]+)+[\.][a-z]{2,3}([\.][a-z]{2})?$/i;
if (email=="") {
      alert("请输入您的邮箱!");
      return false;
    }
if (email.length>25){
     alert("长度太长");
     return false
}
if (!isemail.test(email)){
     alert("不是邮箱");
    return false;
}
}

The above is the detailed content of A way to write js email verification method. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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