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

Component with form

JulienLachโ€ข 260

@JulienLach

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 ! I'm starting to learn JS

I'm in truble with the email check... I've done i think the if empty functions but i don't now how to verify the email , the good format.

Anyone may help ? :)

Community feedback

@MelvinAguilar

Posted

Hello there ๐Ÿ‘‹. Good job on completing the challenge !

I have some suggestions about your code that might interest you.

  • Verifying an email address in JavaScript typically involves using regular expressions or built-in functions to check if the email follows a valid format. Here's a basic example

    function isValidEmail(email) {
      const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
      return emailRegex.test(email);
    }
    
    // Example usage
    const emailToVerify = "[email protected]";
    if (isValidEmail(emailToVerify)) {
      console.log("Email is valid!");
    } else {
      console.error("Email is invalid");
    }
    
  • It seems that the current implementation has validations to display error messages, but there is no mechanism to remove or clear those error messages. Ideally, if a user modifies the input to correct the error, the error message should be removed.
  • Directly manipulating styles in JavaScript can lead to code that is hard to maintain. Create a CSS class with the desired styles and use JavaScript to add or remove that class.
  • Consider organizing your code more efficiently by moving all the document.querySelector calls outside of the event listener and assigning them to variables at the beginning.
  • Additionally, if you've already obtained the element in const firstName, there's no need to use document.querySelector('.first-name') again. You can simply use the variable firstName for subsequent operations.

I hope you find it useful! ๐Ÿ˜„

Happy coding!

Marked as helpful

0

JulienLachโ€ข 260

@JulienLach

Posted

@MelvinAguilar Hello, big thanks for you reply. I will try your suggestions ! I didn't know about your last bullet point, calling variables. I will fix my code

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