Interactive Credit Card Details
A frontend development challenge that calculates age based on day, month, and year inputs.
Challenge provided by Frontend Mentor.
Skills
- Frontend Development
- Accessibility Compliance
- User Interface Design
Timeline
August 2023
Preface
This is a solution to the Interactive card details form challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.
The Challenge
Users should be able to:
- Fill in the form and see the card details update in real-time
- Receive error messages when the form is submitted if:
- Any input field is empty
- The card number, expiry date, or CVC fields are in the wrong format
- View the optimal layout depending on their device's screen size
- See hover, active, and focus states for interactive elements on the page
Learnings
How to manage parent and child component state. Originally, I had rendering issues combining the form with the page content. Make unique components, and passing in state as a prop, solved the rendering issue.
const [values, setValues] = useState(creditCardValues);
<Form values={values} onChange={setValues}/>
Resources
- Updating Arrays in State: This helped structure the form's inputs onChange events.
- Credit Card Validation: Primarily used for informational purposes. As our form is simple enough to not use all these edge cases.