I've protected my website using a password (I don't really need a "real" protection, it's just a small save the date website, no big deal, just don't want people to mind my business ;) )
But the code I've used does not seem to work on mobile version. Whenever I enter the password I chose, I always get the error message of wrong password, even if it's correct. Any idea of how can I possibly solve this?
var password = "please";
var x = prompt("Enter in the password "," ");
if (x.toLowerCase() == password) {
alert("Come right in \n \n You've entered in the right password");
window.location = "index.htm";
}
else {
window.location = "bad.htm";
}
Please look at your line:
var x = prompt("Enter in the password "," ");
Your second parameter is adding a blank space before your answer " ". You should use the blank parameter "".
For example if you type your password: please. Instead of comparing "please" to "please" it will wrongly compare "please" to " please".
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.