Skip to content

sicktooth/newsletter-sign-up-with-success-message

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Frontend Mentor - Newsletter sign-up form with success message solution

This is a solution to the Newsletter sign-up form with success message challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.

Table of contents

Overview

The challenge

Users should be able to:

  • Add their email and submit the form
  • See a success message with their email after successfully submitting the form
  • See form validation messages if:
    • The field is left empty
    • The email address is not formatted correctly
  • View the optimal layout for the interface depending on their device's screen size
  • See hover and focus states for all interactive elements on the page

Screenshot

Desktop view

Links

My process

Built with

  • Semantic HTML5 markup
  • CSS custom properties
  • Flexbox
  • CSS Grid
  • Desktop-first workflow

What I learned

I realized you cannot use querySelectors for jQuery functionalities.

Adding a function to the input element that removes the error message immediately it detects the email was correctly formatted before submission by adding an event listener to the input. See code below:

NOTE: This function is mostly written in jQuery.

const inputValidator = () => {
    const inputValue = input.val();
    if (inputValue.match(regex)) {
        errorLabel.css("display", "none");
        errorInput.removeClass("error__input");
    }
}
input.on("input",inputValidator);

Continued development

In the coming projects, I am building more websites with better animations and focusing on learning React

Useful resources

  • Simplilearn Youtube - This in understanding regex. I really liked the way it was explained from scratch.
  • A place to practice regex - This is an amazing website which helped me in understanding Regex by practising. I'd recommend it to anyone still learning this concept.

Author