Password Input Reject Preset Number of Entries

Looking to create a password input that will reject a preset number of entries, regardless of whether the password is correct.

No database will be used! Since this is not a site that stores sensitive data, password protection is merely part of a game on this site.

A user arrives at an HTML based page and presented with a password input. The password is based upon clues they received previously in a game. I want to reject for example the first 4-5 attempts, even if they are correct. The correct password would probably be stored in a JavaScript with the correct answer redirecting a user to the next page.

Anyone know of a Pen that exists with similar functionality?

Firstly, welcome to the forums.

While we are primarily here to help people with their Free Code Camp progress, we are open to people on other paths, too. Some of what you are asking is pretty trivial in the Free Code Camp context, so you might find that if you’re not getting the instruction and material you need in your current studies, the FCC curriculum will really help you get started. At a modest guess I’d say investing a 4-5 hours working through the curriculum here will really pay off. You can find the curriculum at https://freecodecamp.org.

With your current questions, we don’t have enough context to know what you already know or don’t know, so it is impossible to guide you without just telling you the answer (which we won’t do).

It is pretty typical on here for people to share a codepen / jsfiddle example of what they have tried so that anyone helping has more of an idea of what help is actually helpful.

Please provide some example of what you’ve tried and I’m sure you’ll get more help.

Happy coding :slight_smile:

If you store the password in the JavaScript code, then all a user has to do is view the source code for the page to see the answer. Even if you don’t care about security, the password would still be better stored on the server and user’s answer should be submitted to the server with the server responding back if they got the right answer.

Good point. I neglected to consider this. Wondering if the password could be hashed within the JS.

I suppose I could create a simple DB but was attempting to create an easy solution. This might be the way to go.

If I store the password in a JS similar to the Pen @bnoden3h shared, the script could be minified to make it that much harder to read.

That’s pretty close to what I am looking for - thanks for sharing!