I used the GoDaddy website builder to create this website, limiting my options for customization. However, I am looking to implement password-only access (with the same password for everyone) to a specific page. This will require an input field for the password and a submit button.
As a complete beginner trying to learn on my own (probably very obvious!), I have put together the following code with minimal knowledge, but it seems like something is not right.
function passWord() {
var testV = 1;
var pass1 = prompt('Please Enter Your Password', '');
while (testV < 3) {
if (!pass1)
history.go(-1);
if (pass1.toLowerCase() == "mypassword") {
window.open('http://www.website.com/webpage.html');
break;
}
testV += 1;
var pass1 =
prompt('Access Denied - Password Incorrect, Please Try Again.', '');
}
if (pass1.toLowerCase() != "password" & testV == 3)
history.go(-1);
return " ";
}
input {
background-color: #000000;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: block;
font-size: 16px;
margin: auto;
cursor: pointer;
}
/* Style the submit button */
input[type=submit] {
background-color: #000000;
color: white;
}
/* The message box is shown when the user clicks on the password field */
#message {
display: none;
background: #f1f1f1;
color: #000;
position: relative;
padding: 20px;
margin-top: 10px;
}
#message p {
padding: 10px 35px;
font-size: 18px;
}
<div class="container">
<form action="/action_page.php">
<input type="password" id="pwd" name="pwd" <br><br>
<input type="submit" value="SUBMIT">
</form>
</div>