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

Vanilla JS sign-up form with CSS grid

P
Alexβ€’ 1,990

@AlexKMarshall

Desktop design screenshot for the Intro component with sign-up form coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


Hi, I approached the form validation here with vanilla js, and I think the error highlighting is handled ok. But it doesn't currently prevent the form from being submitted if you haven't filled it out correctly?

Are there good strategies for preventing the form submission (not just disabling the button)?

Thanks :)

Community feedback

Ynnkβ€’ 170

@HYannick

Posted

Hi ! Great work :D

Maybe add a event.preventDefault at the form submission ?

Something like :

const form = document.querySelector("form");

form.addEventListener('submit', (e) => {
 e.preventDefault();
 //Do your things
});
2

P
Alexβ€’ 1,990

@AlexKMarshall

Posted

Awesome, thanks I'll try that.

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