function validateCredentials() {
var username = document.forms["myForm"]["name"].value;
var admin = "admin";
var user = "user";
var master = "master";
if (username == "") {
alert("PLEASE ENTER YOUR USERNAME and PASSWORD");
}
else if (username == user){
window.location.href = "form1.html";
}
else if (username == admin) {
window.location.href = "admin.html";
}
else if (username == master){
window.location.href = "master-admin.html";
}
else{
alert("Please provide a valid username");
}
}
Find the form code below: -
<form method="POST" id="myForm" name="myForm" action="">
<input type="text" name="name" placeholder="Username" id="name" required/>
<br />
<input type="password" name="password" placeholder="Password" id="pass" required/>
<br />
<button type="submit" onclick="validateCredentials()">LOGIN</button><br />
<button type="button">SIGN UP</button><br />
</form>
I am attempting to redirect to different pages based on different credentials, but encountering issues with the login process. Please help me identify the mistake I am making...