我希望电子邮件地址中只允许有一个 at 符号,并且只包含(az、AZ、下划线 (_)、点 (.) 和破折号 (-))。这就是我到目前为止所拥有的。谢谢
var email = document.forms["register"]["email"].value;
var atpos = email.indexOf("@");
var dotpos = email.lastIndexOf(".");
if (atpos < 3 || dotpos < atpos + 4 || dotpos + 2 >= email.length)
{
alert("You have not entered a valid Email address, please check for mistakes and re-submit");
return false;
}