Home  >  Article  >  Web Front-end  >  Summary of JS verification email address format methods_javascript skills

Summary of JS verification email address format methods_javascript skills

WBOY
WBOYOriginal
2016-05-16 15:28:381298browse

The example in this article describes the JS verification email address format method. Share it with everyone for your reference, the details are as follows:

Example 1:

Copy code The code is as follows:
d24c7018113a62baa826c6082aabd4155149ea95ee12bbe752151d007a26c100

function checkRate(input)
{
  var re = /^[_".0-9a-z-]+@([0-9a-z][0-9a-z-]+".){1,4}[a-z]{2,3}$/i;  
  var nubmer = document.getElementById(input).value;
   if (!re.test(nubmer))
  {
    alert("请输入正确格式的邮件地址");
    document.getElementById(input).value = "";
    return false;
   }
}

Example 2:

<script type="text/javascript">
function isValidMail() {
  var TextVal = document.getElementById("TextBox1").value;
  var Regex = /^(&#63;:\w+\.&#63;)*\w+@(&#63;:\w+\.)*\w+$/;
  if (Regex.test(TextVal)){
  alert(true);
  }
  else {
  if (TextVal == "") {
    alert("请输入电子邮件地址!!");
  return false;
  }
  else {
  alert("您好,你输入不正确,请重新输入;");
   document.getElementById("TextBox1").value = "";
  return false;
    }
  }
}
</script>

Copy code The code is as follows:
74a2e33febd7849a0704de2ea4a4dcc25149ea95ee12bbe752151d007a26c100
abac87e70f31fd47161ea84ea7d2e163

I hope this article will be helpful to everyone in JavaScript programming.

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