Hi im trying to create a form that allows a user to log in by a prompt box for a userid. I stored several arrays and if the user id does not match then there has to be an error message. If the user log-in matches then the next prompt box for the password comes up, and i want the same thing to happen with the password where i store arrays and it has to match, if it matches i use the document.write property for logging in successfully. i cant figure out what is wrong with my code, it works but it displays all 3 messages “welcome, invalid username and invalid password” no matter what i input. so the password prompt should not come up until the username is entered correctly with the stored arrays any help would be appreciated:
<body>
<script language=”JavaScript” type=”text/JavaScript”>
var check=””;
var match=”no”
var user_pass
var userid=new Array ();
login[0]=”batman”;
login[1]=”robin”;
login[2]=”spiderman”;
var use_name= prompt(“Please enter your usernaem”);
for (array_counter= 0; array_counter < 3; array_counter++)
{
if (use_name==login[array_counter])
{
var use_pass=prompt (“enter password”);
break;
} else {
continue;
}
match=”no”
}
if (match==”no”)
{
document.write (“Invalid username”);
}
var pass=new Array();
pass[3]=”pass1″;
passi[4]=”pass2″;
pass[5]=”pass3″;
for (array_counter= 3; array_counter < 5; array_counter++)
{
if (use_pass==pass[array_counter])
{
document.write (“logged in successfully!”);
break;
} else
document.write (“Invalid password”);
}
</script>
</body>
</html>