I'm trying to create a fake password screen. But I don't want them to be able to access the next page unless the correct password is entered. When I run the page, and don't enter a password then the alert pops up like it should, but it then goes to the next page anyway. Any and all help would be great, thanks.
function valid(form)
{
if (form.code.value == ""
{
alert("Please enter a password."
return false;
}
else if (form.code.value != "david"
{
alert("Incorrect password entered."
return false;
}
else if (form.code.value == "david"
{
alert("Correct password entered."
return true;
}
}
<form Action="Main.html" method="post" onSubmit="valid(this);">
function valid(form)
{
if (form.code.value == ""
{
alert("Please enter a password."
return false;
}
else if (form.code.value != "david"
{
alert("Incorrect password entered."
return false;
}
else if (form.code.value == "david"
{
alert("Correct password entered."
return true;
}
}
<form Action="Main.html" method="post" onSubmit="valid(this);">