var password;
var pass1="administrator";
password=prompt('Please enter password',' ');
if (password!=pass1)
alert('password is not currect');
else
{
window.location="home.html";
}
I want to make the number of attempts on the password unlimited
If you want to keep prompting until they get it, you can use a do...while
var password;
var pass1 = "administrator";
do {
password = prompt('Please enter password', '');
if (!password) break
if (password === pass1) {
window.location = "home.html";
break; // stop
}
alert('password is not correct');
} while (password != pass1)
If you just want them to be allowed to reload and try again
var password;
var pass1 = "administrator";
password = prompt('Please enter password', ' ');
if (password != pass1)
alert('password is not correct');
else {
window.location = "home.html";
}
remove the else part from your code.
var password;
var pass1="administrator";
password = prompt('Please enter password',' ');
if (password!=pass1)
alert('password is not currect');
Use this code and add breaking statement as you wish to break the loop:
while (true) {
var password;
var pass1 = "administrator";
password = prompt('Please enter password', ' ');
if (password === null) break;
if (password != pass1)
alert('password is not currect');
else {
window.location = "home.html";
break;
}
}