原谅我这么简单的问题。我自己尝试了谷歌但没有运气,这就是为什么在这里寻求帮助。我的 auth() 代码有什么问题?
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript">
<script>
function checkform(f) {
var errMSG = "";
for (var i = 0; i<f.elements.length; i++)
if (null!=f.elements[i].getAttribute("required"))
if (isEmpty(f.elements[i].value))
errMSG += " " + f.elements[i].pass + "\n";
if ("" != errMSG) {
alert("Не заполнены обязательные поля:\n" + errMSG);
return false;
}
}
function isEmpty(str) {
for (var i = 0; i < str.length; i++)
if (" " != str.charAt(i))
return false;
return true;
}
function auth(){
var admin_email = "123@123.123"
var admin_password = "S3cur3Passw0rd"
if(document.pass.GetElemetnById.value() == admin_password && document.email.GetElemetnById.value()== admin_email)
document.writeln('Acess granted')
else document.writeln('Acess denied')
}
</script>
</head>
<body>
<form onSubmit = "return checkform(this)">
<table>
<tr>
<td>email</td><td><input type="text" name="email" required></td></tr>
<tr><td>пароль</td><td><input type="text" name="pass" required></td></tr>
<tr><td><input type="submit"></td><td>
</table>
</form>
</form>
</body>
</html>
所以在提交包含密码和登录名的表单后什么都没有发生