Question: i have made a html code and a js code html : 1234567890 1234567890 * { padding: 0; margin: 0 } table { margin: 0
i have made a html code and a js code
html :
1234567890
|
* {
padding: 0;
margin: 0
}
table {
margin: 0 auto;
margin-top: 200px
}
| |
--------------
js
function validation(username,password){
for(let i=0;i
console.log(data[i].username,username)
if(data[i].username===username && data[i].password===password){
return true;
}
else if(data[i].username===username && data[i].password!==password){
alert("Invalid password");
}
else{
alert("Not a registered username");
}
}
return false;
}
function check() {
var user_name = form1.user.value;
var user_pwd = form1.pwd.value;
if ((user_name == "") || (user_name == null)) {
alert("enter username");
form1.user.focus();
return;
}
else if ((user_pwd == "") || (user_pwd == null)) {
alert("enter password ");
form1.pwd.focus();
return;
}
const status=validation(user_name,user_pwd);
if (status===true) {
alert("you have successfully log in");
form1.submit();
location.replace("login.html");
}
}
and a user json
[
{
"username":"user1@234.com",
"password":"123456"
},
{
"username":"user2@2324.com",
"password":"qwerty"
}
{
"username":"user3@224.com",
"password":"asdfgh"
}
]
----------------
why it dont go to "users json"when i enter password and username in the suer json
and it dont show "incorrect username/[password when i enter wrong password .
can someone help me fix this ?
can someone help me fix it ?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
