Design comparison
SolutionDesign
Solution retrospective
What are you most proud of, and what would you do differently next time?
how learn about how to add form validation to make user experience much better
What specific areas of your project would you like help with?I’m having an issue where the error message for not checking the consent checkbox isn’t appearing. I would appreciate any assistance you could provide to help me resolve this issue
Community feedback
- @KapteynUniversePosted 6 days ago
Ok. First i said you commented it out, tought it was a silly mistake :D but after checking more found the problem:
You used
document.querySelector("#terms + .error")
but in HTML your class error isn't adjacent sibling of the terms.<div class="form-control"> <input type="checkbox" name="terms" id="terms" /> <label for="terms">I consent to being contacted by the team</label> <small class="error"> To submit this form, please consent to being contacted</small> </div>
You need to use
document.querySelector("#terms ~ .error")
0
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