-1
JavaScript 로그인 양식을 만들고 싶은 사이트가 있습니다.자바 스크립트 비밀번호 확인 window.location.replace
완벽한 사용자 이름이 아님 & 비밀번호 로그인,하지만 비밀번호 확인 로그인을 만들고 싶습니다. 사용자가 private.html로 리다이렉트하면 올바른 결과를 얻고 error.html을 잘못 받아들이 길 원합니다.
<script type="text/javascript">
function checkForm() {
x = document.getElementById("holy").value
if (x == "mangos") {
alert("Right Password!");
window.location.replace("private.html");
}
else {
alert("Wrong Password!");
window.location.replace("home.html");
}
}
</script>
<center>
<form class="form-container">
<center>
<div class="form-title"><h2>Login</h2></div>
<div class="form-title">Username</div>
<input class="form-field" type="text" name="username" /><br />
<div class="form-title">Password</div>
<input class="form-field" type="password" id="holy" name="password" /><br />
<div class="submit-container">
<button onclick="checkForm()" class="submit-button">Login</button>
</div>
</center>
</form>
분명히, 함수의 경고 섹션은 작동하지만 다음 window.location.replace가 전혀 작동하지 않는 것입니다 코드의 다음 부분 :
이
은 HTML입니다. 대신 URL은.com/password.html?username=asd&password=mangos
이되어야합니까?
고맙다 Aravind, 그것은 완벽하게 작동합니다! – FoxInFlame
단추의 html 부분에 반환 값을 추가해야했지만. onclick = "return checkForm() – FoxInFlame