Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

interactive-card-details-form-main

OsatohanmwenT• 420

@OsatohanmwenT

Desktop design screenshot for the Interactive card details form coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
2junior
View challenge

Design comparison


SolutionDesign

Solution retrospective


could someone help me with the identify the problem with the javascript i wrote being check and can't seem to find the problem

Community feedback

HelloTechTinu• 640

@tinuola

Posted

Hello, Technically, the form works -- it submits as long as all the fields are completed. What is missing in the code is the logic to check that the information entered in the fields are in the accurate format. If the user input is incorrect, then the form should not submit. Users should get error messages about how the data should be entered.

For example, in the current code, the card number, month, year and cvc fields are allowing/accepting alphabetical letters. This should be set up/refactored so that only numeral values (0-9) are accepted.

You need to update the logic that checks the fields to also include a check that the fields are getting the properly entered data.

Marked as helpful

0
P
markus• 1,430

@markuslewin

Posted

You have to remove the errors before you check the values again, right? 🙂

confirmBtn.addEventListener("click", () => {
  cardNumberInput.classList.remove("error-border");
  cardNumberInput.nextElementSibling.innerHTML = "";
  cardOwnerInput.classList.remove("error-border");
  cardOwnerInput.nextElementSibling.innerHTML = "";
  cardExpiryMonth.classList.remove("error-border");
  cardExpiryYear.classList.remove("error-border");
  cardExpiryYear.parentElement.nextElementSibling.innerHTML = "";
  cardCVC.classList.remove("error-border");
  cardCVC.nextElementSibling.innerHTML = "";
  error = false;

  if (cardNumberInput.value === "") {
    cardNumberInput.classList.add("error-border");
    cardNumberInput.nextElementSibling.innerHTML = "Cannot be empty";
    error = true;
  }

  // other checks
}

Marked as helpful

0

OsatohanmwenT• 420

@OsatohanmwenT

Posted

@markuslewin thanks it also has another problem the error page is working fine but after test the error page if i fill the form correctly, the details aren't displayed

0
P
markus• 1,430

@markuslewin

Posted

@OsatohanmwenT Hmm, I can only see the old code on GitHub. I think the error = false; in my comment above should help with that!

Marked as helpful

0
OsatohanmwenT• 420

@OsatohanmwenT

Posted

@markuslewin thanks

1

Please log in to post a comment

Log in with GitHub
Discord logo

Join 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