Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted over 3 years ago

Form validation using tailwind and vanilla js

tailwind-css
Priyanka•380
@cssbubble
A solution to the Intro component with sign-up form challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)
Code
Couldn’t fetch repository

Please log in to post a comment

Log in with GitHub

Community feedback

  • Grace•32,130
    @grace-snow
    Posted over 3 years ago

    Hi

    You need to remove the alert on this and I'm seeing some alignment/positioning issues on mobile when the errors are visible. I'll add a screenshot on slack so you can see what I mean.

    You would be better letting the error icon be a background image rather than have it in the html, or it could go in a pseudo element.

    I can see invalid html where it says try it free in that purple box. You shouldnt have an anchor tag wrapping a paragraph. I don't think that content would be a link anyway though. Where would it go? The sign up form is already directly below it.

    I don't think the Sr only h2 is necessary on this either. The content is pretty clear what it is. If anything, you could use aria-labelledby on the form element and link it to the "try it free text" if you really want to label the form.

    In the form itself there are some important principles to learn in this challenge, it's a great practice ground

    • well done for labelling all inputs!
    • they also need aria describedby pointing to the id of their associated error container (I assume the hidden class is setting the errors to display none? They need to be display none by default so they don't get read as a field description at the wrong time)
    • the error containers also need an aria-live attribute to make sure they are announced to screenreaders when they appear
    • I can't read the css it's too long. If you're going to use a utility class approach, that's your choice, but it is essential to have some build tooling to purge it so you're only loading what you need for that project. Don't make people download a massive render blocking css file for a small component
    • the js can be much simpler. All it needs to do is toggle one class on the wrapper around each input, or set CustomValidity on the input or even toggle a custom data attribute. Literally every other bit of styling can be done in css to make the error show up (using child or sibling selectors depending on approach )

    I hope this is all helpful, good luck

    Marked as helpful
  • Priyanka•380
    @cssbubble
    Posted over 3 years ago

    Thanks, Grace, for your detailed reply.

    1- Can you share me the the resources to learn more about Aria labels? I would love to know and learn more about it.

    2- Yes, I am using Tailwind css CLI. I did it to learn how to use cli so that I can manage all the projects using one github repository and interlink css, images, js and other files.

    1. Thanks for pointing out 4th point. I was unaware of that. I will learn more about it and improve.

    2. Will improve js too.

    Very helpful.

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

How does the accessibility report work?

When a solution is submitted, we use axe-core to run an automated audit of your code.

This picks out common accessibility issues like not using semantic HTML and not having proper heading hierarchies, among others.

This automated audit is fairly surface level, so we encourage to you review the project and code in more detail with accessibility best practices in mind.

How does the CSS report work?

When a solution is submitted, we use stylelint to run an automated check on the CSS code.

We've added some of our own linting rules based on recommended best practices. These rules are prefixed with frontend-mentor/ which you'll see at the top of each issue in the report.

The report will audit 1st-party linked stylesheets, and styles within <style> tags.

How does the HTML validation report work?

When a solution is submitted, we use html-validate to run an automated check on the HTML code.

The report picks out common HTML issues such as not using headings within section elements and incorrect nesting of elements, among others.

Note that the report can pick up “invalid” attributes, which some frameworks automatically add to the HTML. These attributes are crucial for how the frameworks function, although they’re technically not valid HTML. As such, some projects can show up with many HTML validation errors, which are benign and are a necessary part of the framework.

Frontend Mentor for Teams

Frontend Mentor for Teams helps companies and schools onboard and train developers through project-based learning. Our industry-standard projects give developers hands-on experience tackling real coding problems, helping them master their craft.

If you work in a company or are a student in a coding school, feel free to share Frontend Mentor for Teams with your manager or instructor, as they may use it to help with your coding education.

Learn more

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