Design comparison
Solution retrospective
I written javascript code which is too complex and not the best way to solve however i tried my best to minimize it suggestion are welcome.
Community feedback
- @RagudosPosted about 1 year ago
I like that you followed the desktop design splendidly and how you used if-statements for invalid values!
To make your design mobile-friendly, I recommend:
- Use CSS properties
- Use the clamp(), min(), or max() function in CSS.
For dynamic styling:
- With CSS properties, you can do something like "element.style.setProperty(propertyName, value);" which will help you shorten your code a bit.
You can separate logic for each validation of content. For example, you can start with the year, then the month, then the day. After that, for each invalid format, you can decide what to change in the DOM to show the error instead of simultaneously showing all possible error messages despite the possibility of only one input being incorrect.
Lastly, I recommend using element.textContent or element.innerText instead of innerHTML if you are only inserting text inside an element.
Marked as helpful0
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