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

BEM, JS

Pavel Drow 220

@Paveldrow

Desktop design screenshot for the Intro component with sign-up form coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


Hello everyone! did js validation, but it didn't quite work out. I can not find information on how to remove the message about incorrect validation. I used createElement in which I added various validation error messages and added this element via cloneNode. I understand that each time a field is validated, the invalid message should be removed, but I can't figure out how to do it. deleting a clone via remove () fails. And the error messages are multiplying! It could have been made easier by adding the error text right away in DOM and showing it by adding a class or display. I will be grateful for advice or a link to an article with a solution!

Community feedback

P
tediko 6,680

@tediko

Posted

Hello! If you want to keep your app like that you have to create new function to remove unnecessary errors and attach it to your listener.

const  removeErrorMessage  =  ()  =>  {
   const  errorElements  =  document.querySelectorAll('.invalid-message');
   if (errorElements.length  ===  0) return;

   errorElements.forEach(error  =>  {
   error.remove();
 })
  1. errorElements variable grabs all error elements. 2. If statement checks if there is something to remove, if not function stop running. 3. If there are errors to remove, the forEach will remove every error message.
1

Pavel Drow 220

@Paveldrow

Posted

it works, thanks!) yes, it was necessary to use an array and forEach)

Can you please tell me, is it possible to do such a check somehow easier and more correctly? or is this a normal solution?

0

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