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

Base-Apparel-coming-soon-page

Godstimeβ€’ 330

@iceberg61

Desktop design screenshot for the Base Apparel coming soon page coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


πŸ‘Ύ Hello, Frontend Mentor coding community.

This is my solution for the Base-Apparel-coming-soon-page challenge.

Problem: Well yes I know you seen the JS fileπŸ˜‚. It looks horrible right. if you could give me any resources to help me understand form validation that will be great.

Ill be happy to hear any feedback and advice!

Community feedback

P
Eileen dangeloβ€’ 1,600

@Eileenpk

Posted

Hi Godstime! your project looks good.

Forms were hard for me too when I started, and validation can get messy. Here are a few things I see that might help.

In your HTML:

  • Add an aria-label to the email input for accessibility
<input type="email" name="email" id="email" placeholder="Email Address" aria-label="Email Address">

In your JS:

  • Change the event listener to use input event instead of click, this will fire every time the input field changes
  • Add or remove classes instead of manipulating them
  • Check for an empty input before checking for a pattern match, currently if I try to submit the form with an empty email input, no error is shown
email.addEventListener('input', validateEmail);

function validateEmail() {
  if (email.value.trim() === '') {
    paragraph.innerHTML = 'Please provide an email';
    email.classList.remove('bg-form');
    error.src = '';
  } else if (!email.value.match(patterns)) {
    paragraph.innerHTML = 'Please provide a valid email';
    email.classList.add('bg-form');
    error.src = '../images/icon-error.svg';
  } else {
    paragraph.innerHTML = 'Please submit the email';
    email.classList.remove('bg-form');
    error.src = '';
  }
}

Hope you found this helpful!

Marked as helpful

1

Godstimeβ€’ 330

@iceberg61

Posted

@Eileenpk You literally just explain what i have been busting my ass off in literally 2 minutesπŸ˜‚πŸ˜‚πŸ˜‚πŸ˜‚. Thanks alot. it Was very helpful. Much love from Godstime

0
Abdul Khalid πŸš€β€’ 72,160

@0xabdulkhalid

Posted

Hello there πŸ‘‹. Congratulations on successfully completing the challenge! πŸŽ‰

  • I have other recommendations regarding your code that I believe will be of great interest to you.

JAVASCRIPT 🟑:

  • The way you declared variables are need to be well structured and organized
  • Take a look at the following example code which describes an efficient way of declaring variables
const firstName = "Your";
const lastName = "Name";
const emailAddress = "[email protected]";
const password = "supersecret";
  • instead try this,
const firstName =  "Your",
       lastName =  "Name",
       emailAddress = "[email protected]"
       β€’β€’β€’                
       β€’β€’β€’         // n number of declarations
       password = "supersecret";   // make sure to add a semicolon at end of last declaration
  • This single line declaration with separated commas will helps you to have a better structured code and improves readability though

.

I hope you find this helpful πŸ˜„ Above all, the solution you submitted is great !

Happy coding!

Marked as helpful

0

Godstimeβ€’ 330

@iceberg61

Posted

@0xAbdulKhalid i WIll definitely start structuring my variables THanks alot for the feedback

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