Some pretty simple code, although i cant figure out why its not working properly. When run, it asks for password but does nothing once password has been entered. It is supposed to give the user 3 attempts to enter password correctly, displaying correct/incorrect password where appropriate. Could anyone help point out what ive done wrong here, thanks :)
Here is my code:
<html>
<head>
<title>Password Entry</title>
<script>
function passwordEntry(vP)
{
i=0
password = prompt("Please enter password")
i++
if(password != vP){
do{
i++
password = prompt("Password incorrect" <br> "Please re-enter password")
}while (password != vP && i<=3)
}
if(password == vP){
alert("Password correct")
}
}
var validPassword = "123XY"
passwordEntry(validPassword)
</script>
</head>
</html>
"Please re-enter password"` with `"Password incorrect\nPlease re-enter password"`. – Ivar Dec 17 '19 at 21:40
and links to a javascript alert?](https://stackoverflow.com/questions/591130/can-i-add-a-br-and-links-to-a-javascript-alert) – AndrewL64 Dec 17 '19 at 21:41