Submitted 10 months ago
Responsive Newsletter Sign Up with HTML CSS and Javascript
@kevinebenhezer
Design comparison
SolutionDesign
Solution retrospective
I successfully made the pop up success message, with modal. But the problem is, my modal pop up message is only showing for like 0.1 second, like a flash. And i cant fix it. Anybody know how to fix that? thank you.
Community feedback
- @IamparvesPosted 10 months ago
The reason it is happening is because when you submit a form it by default changes the URL and the page reloads.
In the form submit event listener you added
e.preventDefault()
inside if condition. Instead do it outside any condition.form.addEventListener("submit", (e) => { e.preventDefault(); if (email.value == "") { error(); } else { success(); } });
Marked as helpful0@kevinebenhezerPosted 10 months agohello @Iamparves, thank you very much! thats worked perfectly. I'm super new to js, so i didnt really know code order in js. Once again thank you!
0
Please log in to post a comment
Log in with GitHubJoin 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