My code doesn’t redirect to my other html file and I have no Idea why. The login function works fine but it just doesn’t redirect for some reason.
function login(){
let username = document.getElementById("user").value;
let password = document.getElementById("password").value;
if (checkUser(username,password)){
window.location.assign("Student.html");
}
else if (username =="Admin" && password == 7800){
location.assign('Librarian.html');
}
else {
alert("Incorrect Username/Password or Not Registered");
}
}
<div class="Log">
<div class="login">
<form class="needs-validation">
<h1 class="text-center pt-3"> Log in Form</h1>
<hr />
<div class="form-group was-validated">
<label class="form-label" for="user">Username</label>
<input class="form-control" type="text" id="user" />
<div class="invalid-feedback">
Invalid Username
</div>
</div>
<div class="form-group was-validated">
<label class="form-label" for="password">Password</label>
<input class="form-control" type="password" id="password" />
<div class="invalid-feedback">
Invalid Password
</div>
</div>
<div class="form-group">
<input class="form-check-input" type="checkbox" id="checkRemember" />
<label class="form-check-label" for="check">Remember me</label>
</div>
<button class="btn btn-success w-100 mb-3" id="btn_Log" onclick="login()">Log In</button>
<div class="login-register">
<p>Don't have an account? <a href="Register.html" class="register-link">Register</a></p>
</div>
</form>
</div>
</div>
<script src="logreg.js"></script>
I have try the different ways to redirect and none of them worked. I don’t know what to do.