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

Summary of JS verification email address format methods_javascript skills

WBOY
Release: 2016-05-16 15:28:38
Original
1330 people have browsed it

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:

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;
   }
}
Copy after login

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 after login

Copy code The code is as follows:

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

Related labels:
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