【发布时间】:2020-05-29 20:14:43
【问题描述】:
我正在尝试创建一个密码登录页面,但是当您输入正确的密码时,它只会提醒用户它是正确的。但我希望它发出警报并重定向到另一个页面。例如,google.com。这是我的代码,任何帮助将不胜感激。
// Function to check Whether both passwords
// are same or not.
function checkPassword(form) {
password = form.pass.value;
correct = "admin";
// If password not entered
if (password == '')
alert("Please enter Password");
// If confirm password not entered
else if (correct == '')
alert("Please enter confirm password");
// If Not same return False.
else if (password != correct) {
alert("\nPassword is incorrect. Please try again...")
return false;
}
// If same return True.
else {
alert("Password is correct, press okay to continue.")
return true;
}
}
我对编码非常陌生,是从 YouTube 视频中获得的,所以我对 JavaScript 几乎一无所知,但我对 HTML 和 CSS 有所了解。
【问题讨论】:
-
使用 window.location.href = 'url'
-
这能回答你的问题吗? How do I redirect to another webpage?
标签: javascript authentication passwords