Design comparison
SolutionDesign
Solution retrospective
Hi, I approached the form validation here with vanilla js, and I think the error highlighting is handled ok. But it doesn't currently prevent the form from being submitted if you haven't filled it out correctly?
Are there good strategies for preventing the form submission (not just disabling the button)?
Thanks :)
Community feedback
- @HYannickPosted over 4 years ago
Hi ! Great work :D
Maybe add a
event.preventDefault
at the form submission ?Something like :
const form = document.querySelector("form"); form.addEventListener('submit', (e) => { e.preventDefault(); //Do your things });
2
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord