[英]How to validate an email address using JavaScript?
i am trying to doing input validation its my complete code but it is not working well. 我正在尝试进行输入验证,这是我完整的代码,但是效果不佳。
<html>
<head>
<title>Testing Validation</title>
<script type = "text/javascript">
function getvalue()
{
value = document.getElementById('myId').value;
if(value < 'a' || value > 'z' || value != '@' && value != '.')
{
alert("Not a valid E-mail adress");
}
}
</script>
</head>
<body>
<form name = "frm">
<input type="text" name="input" size="40" id="myId" />
<input type = "submit" name = "submit" onclick="getvalue()" />
</form>
</body>
</html>
If you want to check that an email is valid, look for solutions using regex. 如果要检查电子邮件是否有效,请使用正则表达式查找解决方案。 This has been discussed before on SO: Using a regular expression to validate an email address 前面已经在SO上对此进行了讨论: 使用正则表达式来验证电子邮件地址
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.