GithubHelp home page GithubHelp logo

stacy-riley / interactive-card-details-form Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 5.8 MB

A mobile responsive credit card component with verification capability.

Home Page: https://stacy-riley.github.io/interactive-card-details-form/

CSS 25.08% HTML 33.78% JavaScript 41.14%

interactive-card-details-form's Introduction

Frontend Mentor - Interactive card details form

This is a solution to the Interactive rating component challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.

Table of contents

Overview

This component is a mobile responsive credit card component. The user has five input fields to enter their credit card information into. There are functions in place to verify the user information. These include empty fields, characters other than numbers, and number limitations.

The challenge

Users should be able to:

  • View the optimal layout for the app depending on their device's screen size
  • See hover states for all interactive elements on the page
  • Enter information that is verified and display error messages when incorrect
  • See the "Thank you" card state after submitting the card information

Screenshot

Links

My process

I began with the mobile version and then moved on to creating the desktop version. After the app was styled, I added the JavaScript functions that verified the user data.

Built with

  • Semantic HTML5 markup
  • CSS custom properties
  • Flexbox
  • Mobile-first workflow
  • JavaScript

What I learned

I like how all the functions runs with the submit button. Also, I got to the end of the event listener and wanted to learned how to grab the data the form had taken in. I was able to do that by creating an object named ccInfo and console.log the results.

  //Click event to listen for the submit button:
confirmButton.addEventListener("submit", function(event){
    event.preventDefault();
    verifyName();
    verifyCardNumber();
    verifyMonth();
    verifyYear();
    verifyCvc();
    //Add checks for input fields
    if( verifyName() === true && 
        verifyCardNumber() === true && 
        verifyMonth() === true && 
        verifyYear() === true &&
        verifyCvc() === true){
        
        ccPage.style.display = "none";
        thankYouPage.style.display = "block";
     } 
    //Gather the data
    const ccInfo = {
        cardholderName: cardholderName.value,
        cardNumber: cardNum.value,
        expirationMonth: expMonth.value,
        expirationYear: expYear.value,
        cvcCode: cvcCode.value
      };
      
      //Displaying entered data here so you can see that the code works:
      console.log(ccInfo);
});

Continued development

I'm all about getting better at collecting and organizing user data so I can help the website owner make things better for everyone. The goal is to give users a smoother experience and some valuable insights to the site owner.

Useful resources

Author

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.