Skip to content
  • Learning paths
  • Challenges
  • Solutions
  • Articles
  • Unlock Pro
  • Log in with GitHub
Submitted 6 months ago

Contact form component

Sandaruwan•510
@Sandaruwan7056
Preview site (opens in new tab)View code (opens in new tab)
Desktop design screenshot for the Contact form coding challenge
This is a solution for...Contact form
  • HTML
  • CSS
  • JS
2junior
View challenge

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

  • KapteynUniverse•2,900
    @KapteynUniversePosted 6 months 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 GitHub

Join 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
Frontend Mentor logo

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub