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

Newsletter sign up form with custom validation

P

@srijanss

Desktop design screenshot for the Newsletter sign-up form with success message coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
2junior
View challenge

Design comparison


SolutionDesign

Solution retrospective


What are you most proud of, and what would you do differently next time?

I got to learn about,

  • The aria-live attribute to make my form more accessible. This is announce the error messages who is using assistive technologies.
  • Creating gradients and different configurations related to it.
  • FormData and how it can be used to get user input from the form. It's really neat and handy feature.

What challenges did you encounter, and how did you overcome them?

Since there was only one input element of type email, I tried to use Constraint validation API to validate the form. And I tried to use :invalid , :focus:invalid pseudo states of input in CSS. As I have required attribute present in the input, it set the :invalid state for the input element on page load. So, invalid state related CSS was always showing in my app. So, to fix that I remove :invalid related CSS and used .invalid class instead to handle valid and invalid states from JS.

What specific areas of your project would you like help with?

Open for feedback

Community feedback

1deadjoe 260

@1deadjoe

Posted

This solution is very neat and close-to-perfect. I like the transitions you have used. How do you get the input to clear after dismissing the message?

1

P

@srijanss

Posted

@1deadjoe

Thanks for the feedback.

I've used Javascript to clear the text on input

dismissMessageBtn.addEventListener("click", () => {
  emailInput.value = "";
  toggleFormAndSuccessMessageVisibility();
});

Hope this helps. Happy coding.

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