Design comparison
SolutionDesign
Solution retrospective
how do you achieve tab spaces in a form?.e.g 0000 0000 0000 0000
Community feedback
- @warrenleePosted over 2 years ago
Hey Bismarck! Good effort on this challenge! I just finished this and it was not easy.
If you want to archive the card number format you'll need to hook the input to an event listener, most likely
keydown
and transform thevalue
that's in the event object and the apply the following regex. So something likeinputElement.addEventlistener('keyup', function(event) { event.target.value = event.target.value .replace(/[a-z\W]/gi, "") // prevent any other characters being inputed other than numbers .replace(/(.{4})/g, "$1 ") // for every 4 characters append a space after .trim(); })
Here is my solution on this. I used React. https://bitbucket.org/warrenlee/frontend-mentor/src/master/interactive-card-details-form/src/components/Form/index.jsx
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