我想用html和javascript做一個簡單的登錄表單,但是每當我使用window.location.replace改變到下一個頁面時,它永遠不會工作。如果我得到的密碼錯誤,它會起作用,但如果我把它正確的話,它會把表單提交到url(url.com/?pswrd=password)。我不想爲此項目使用SQL或任何類型的密碼保護。window.location.replace登錄表單問題(html,javascript)
<form onsubmit="checkForm(this)">
<input id="password"
type="password"
name="pswrd"/>
<input id="btn" onclick="checkForm(this.form)" type="submit" value="Login" class="hvr-float-shadow"/>
</form>
</font>
<script>
function checkForm(form) {
if(form.pswrd.value == "[censored]") {
window.location.replace('/indexproxy.php')
}
else if(form.pswrd.value == "[censored]") {
window.location.replace('/indexproxy.php')
}
else if(form.pswrd.value == "[censored]") {
window.location.replace('/indexproxy.php')
}
else if(form.pswrd.value == "[censored]") {
window.location.replace('/indexproxy.php')
}
else if(form.pswrd.value == "[censored]") {
window.location.replace('/indexproxy.php')
}
else if(form.pswrd.value == "[censored]") {
window.location.replace('/indexproxy.php')
}
else {
alert("Incorrect access code, please try again.");
}
};
</script>
<font face=arial color=white size=2>
<p>All access codes are CaSe SeNsiTIVE</p>
但我也想要的功能按回車檢查形成。 –