
Ping-coming-soon-page with client-side data validation
Design comparison
Solution retrospective
Having practiced somewhat on previous projects, implementing client-side data validation went much quicker for me this time out.
What challenges did you encounter, and how did you overcome them?I found that matching up some of the colors was a little difficult on this project. I ended up fiddling with opacity
settings until things looked right.
Nothing specific. This project was a little easier than the last one that I submitted. I received some excellent feedback on that one that I was able to incorporate into this one.
Community feedback
- @catherineisonlinePosted about 2 months ago
Hello there, nice solution!
- You might have missed it but you accidentally or did not, create a global variable right inside the function, which makes no sense. Maybe better to move it from there or just pass directly the
input.value
?
form.addEventListener("submit", (evt) => { THIS ONE 👇 email = input.value; if (isValidEmail(email)) { removeErr(); ....
- I wonder why you set value of the
input
tonull
if by default it'sstring
type? I guess it's better to reset it back to string unless there are other intentions. 😅 And you might not need theevt
here either
window.addEventListener("load", (evt) => { THIS ONE 👇 input.value = null; removeErr(); });
- You might need to move away
preventDefault
in the form submission out of the else block as it will work only when the form is invalid. Otherwise, when I successfully submit the form, it tries to make a post request which isn't functional and breaks the page 😵
if (isValidEmail(email)) { evt.preventDefault(); removeErr(); alert("Email address is valid"); } else { if (!email) { addErr("Whoops! It looks like you forgot to add your email"); } else { addErr("Please provide a valid email address"); } } });
Marked as helpful1 - You might have missed it but you accidentally or did not, create a global variable right inside the function, which makes no sense. Maybe better to move it from there or just pass directly the
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