Skip to content

BrnCosta/interactive-card-details

Repository files navigation

Frontend Mentor - Interactive card details

This is a solution to the Interactive card details form challenge on Frontend Mentor.

Table of contents

Overview

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

Screenshot

Links

My process

Built with

  • HTML5
  • Javascript
  • Tailwind CSS
  • Mobile-first workflow

What I learned

Basics of Tailwind CSS

<link rel="stylesheet" href="./tailwind/styles.css">

<label id="error-name" class="text-[12px] tracking-widest text-red-400"></label>

How to use regex

var cardNumber = e.target.value
  .replace(/\D/g, "")
  .replace(/(\d{4})(\d)/, "$1 $2")
  .replace(/(\d{4})(\d)/, "$1 $2")
  .replace(/(\d{4})(\d{1,4})/, "$1 $2")
  .replace(/( \d{4})\d+?$/, "$1");

Useful resources

Author

  • LinkedIn - Bruno Costa
  • Frontend Mentor - @BrnCosta
  • Twitter - @_brnCosta

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published