Interactive Rating Component - Vanilla JS, CUBE CSS, accessibility

Solution retrospective
With this project I have tried to keep accessibility in mind; although I'm unsure if it is the correct / ideal implementation. The select buttons are a part of a fieldset
with role="radiogroup"
and a legend
that is visually hidden. As the card is a form
, I included error checking so that if the form is submitted without selecting a rating, then an error message is displayed. I have not looked into fully checking accessibility but I think that the error message would be announced when using a screenreader because of the role="alert"
attribute:
<strong class="alert" id="error-msg" role="alert" hidden>Select a rating from 1 to 5</strong>
This seems like a sensible solution as it means the error message is styled to match the card rather than being a browser-styled popup as with other form inputs / elements.
Please log in to post a comment
Log in with GitHubCommunity feedback
No feedback yet. Be the first to give feedback on Adam Wozniak's solution.
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