/newsletter-form

FEM Challenge - HTML Form Validation

Primary LanguageTypeScript

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

Links

Built with

  • Popover Api
  • Popover Api polyfill
  • HTML Form Validation
  • Responsive Design
  • Fluid typography
  • Responsive images with srcset
  • Semantic HTML5 markup
  • Vite
  • Normalize CSS
  • Netlify
  • CSS custom properties
  • Flexbox
  • Mobile-first workflow

What I learned

A few of what I think were my best code snippets

HTML

<!--using srcset-->
<img
   class="...."
    srcset="img1.svg 375w,
            img2.svg 376w
    "
    sizes="100%"
    src="./assets/images/illustration-sign-up-mobile.svg"
    alt="sign up image"
          
        />
  <button
    popovertarget="success"
    popovertargetaction="show"
    class="full-width line-height btn popoverBtn"
    ><button>
  <dialog
        class="modal"
        id="success"
        popover="manual"
      ></dialog>
    
  <button
          class="...."
          popovertarget="success"
          popovertargetaction="hide"
        ></button>

CSS

#email:invalid:is(:hover,:focus) {
  background-color: var(--tomato-light);
  color: var(--tomato-dark);
}

JS

      dialog.showPopover(); 

Continued development

I still have alot to learn about the popover API, dialog element and the popover polyfill does not work.

Useful resources

Author