r/learnjavascript • u/Successful-Throat621 • 23d ago
Simple Password input field
Hi all, I've been learning webcoding recently and Ive been wanting to make a website to use as a prop in my tabletop games.
My biggest desire right now is to do a password input where submitting an incorrect input displays an error message, while the correct input provides a redirect to a new page.
Since this will only be for my friends and wont host any private data, I'm not too concerned for heavy security, but most resources online are for actual websites and online security. Whats the best way for me to implement something like this?
View all comments
Show parent comment
2
u/efari_ 22d ago edited 22d ago
Man, the boilerplate you decide to use just to prevent the form submission from reloading the page.
Instead of getting the DOM element, adding an event listener and then preventDefault, You could just add “action” or even “onSubmit” param to the form to call a js function