Skip to content

Responsive newsletter sign-up form allowing users to submit their email. Implemented form validation for empty fields and incorrect email formats. Users receive success messages upon submission. Enhanced user experience with hover and focus states for interactive elements.

Notifications You must be signed in to change notification settings

ObiFaith/Newsletter_-_Frontent_Mentor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 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

Note: Delete this note and update the table of contents based on what sections you keep.

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

Newsletter Invalid State

Links

  • Live Site URL: link
  • Solution URL: link

My process

Built with

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

What I learned

  • Regex (Regular Expression)
  • window.location Object
  • event.preventDefault()
window.addEventListener('load', adjustImgSrc);
window.addEventListener('resize', adjustImgSrc);

submitBtn.addEventListener('click', event => {
    event.preventDefault();

    const inputValue = document.querySelector('input').value;
    let checkEmail = inputValue.match(/\b[A-Za-z0-9._+%-]+@[A-Za-z]+\.[A-Za-z]{2,}\b/);

    if(!checkEmail){   
        errorMsg.classList.add('is_visible');
        errorMsg.parentElement.nextElementSibling.classList.add('input-error');
    }
    else
        window.location.href = `${window.location.origin}/subscribe.html?${inputValue}`; 
})

Useful resources

  • Regex - This helped me practice and test Emaill address pattern.
  • Window Location - This is an amazing article which helped me finally understand Window Location Object.

Author

About

Responsive newsletter sign-up form allowing users to submit their email. Implemented form validation for empty fields and incorrect email formats. Users receive success messages upon submission. Enhanced user experience with hover and focus states for interactive elements.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published