Home >Web Front-end >JS Tutorial >Summary of JS verification email address format methods_javascript skills
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:
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 = /^(?:\w+\.?)*\w+@(?:\w+\.)*\w+$/; if (Regex.test(TextVal)){ alert(true); } else { if (TextVal == "") { alert("请输入电子邮件地址!!"); return false; } else { alert("您好,你输入不正确,请重新输入;"); document.getElementById("TextBox1").value = ""; return false; } } } </script>
I hope this article will be helpful to everyone in JavaScript programming.