How can I block a user after 3 attempts? I am doing a username and password login. They ask me that if a user made 3 failed attempts to log in, the account should be blocked, according to the JavaScript function I would have to block the user after 3 failed attempts, but the loop only stays in "You have 2 attempts left" and although I make a mistake again, it just stays at "You have 2 attempts left".
Your error is because you have a variable that you always declare to be 3 when the login function is called .
What you have to change is the code to this way:
In this way it will go down until it reaches 0.
I hope the answer serves you.