Design comparison
Solution retrospective
I need help with 2 things:
-
How do I get the form error message to go away when user clicks outside of input space?
-
How do I get the dark overlay on the body when the mobile nav is deployed?
Thanks!
Community feedback
- @GerbenDolPosted over 4 years ago
Hi Diarrah! 👋🏻
Your solution looks great! Regarding your questions:
- Getting the error message to only appear when the input is focussed is a bit hard with your current structure. You currently have a label around your input, which isn't really doing anything you'd need a label for. If you can remove this, so that the input and the error are on the same depth you could write a selector like this to make it work I think:
.form-control.error input:focus ~ small
and set it to block in this case. That should only have the error show when the error class is active and the input is focussed. - When you toggle your menu you could also toggle a div or pseudo-element that has some styling like this:
position: fixed; top: 0; right: 0; bottom: 0; left: 0; background-color: rgba(0, 0, 0, .5);
. So you just throw a dark layer on top of your page. Just make sure to set the z-index to the correct value so it's under your menu.
Hope this helps! If not, let me know and we'll figure it out on Slack! 😁
3@DiarrahPosted over 4 years ago@GerbenDol Took your advice on the mobile nav overlay div & it worked perfectly! Thank you!
1 - Getting the error message to only appear when the input is focussed is a bit hard with your current structure. You currently have a label around your input, which isn't really doing anything you'd need a label for. If you can remove this, so that the input and the error are on the same depth you could write a selector like this to make it work I think:
- @mattstuddertPosted over 4 years ago
Hey Diarrah, Gerben has already given you some great suggestions. Another option for re-validating the form when the user clicks out of the input would be to add a
blur
event listener to theinput
in your JS. Given your JS code, you could change thesubmit
listener on yourform
to be ablur
listener on yourinput
. This would show and hide the error message sooner, which would give your "users" a faster feedback loop.Great work on this challenge!
1
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