我正在尝试对我的完整代码进行输入验证,但效果不佳。
<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>
答案 0 :(得分:2)
如果要检查电子邮件是否有效,请使用正则表达式查找解决方案。之前已在SO上讨论过这个问题:Using a regular expression to validate an email address