Design comparison
Solution retrospective
- What did you find difficult while building the project?
I find it difficult to find out how I can change the look of the page after valid submitting. First I wanted to change the content after the submitting was successful but the page refreshed by its own and no changes appear. I decided to not let the site refresh after submitting by giving the submitting a event.preventDefault()
to be able to change the content.
- Which areas of your code are you unsure of?
I am unsure if I am doing it right.
form.addEventListener("submit", (event) => {
if (!email.validity.valid) {
event.preventDefault();
} else if (email.validity.valid) {
event.preventDefault();
document.querySelector("#header").innerHTML = "";
document.querySelector("#header").innerHTML = "<img class='success' src='./assets/images/icon-success.svg' />";
document.querySelector(".main__h2").textContent = "Thanks for subscribing!";
document.querySelector("ul").classList.add("hidden");
document.querySelector(".buttonone").classList.add("hidden");
document.querySelector(".buttontwo").classList.remove("hidden");
document.getElementById("canvas").style['flex-direction'] = "column";
document.getElementById("canvas").style['align-items'] = "flex-start";
document.getElementById("canvas").style['max-width'] = "400px";
document.querySelector("form").classList.add("hidden");
document.querySelector(".main__p").classList.add("hidden");
document.querySelector(".main__pp").classList.remove("hidden")
document.querySelector(".email-mess").textContent = email.value;
}
});
I decided to give my valid if statement as well an event.preventDefault()
because I didn't find any solution where I can change the look of the site while letting the form to submit because it refreshes the site. Maybe someone of you can help me out there.
- Do you have any questions about best practices?
If there is any suggestion for better practice I would appreciate it.
Community feedback
- Account deleted
Yeah mate that is wrong :3 !
Try to built each letter as different component and when submitting change opacity from 1 to 0 on the first message and from 0 to 1 on the other message, and also display from none tp block and vice versa.
Hope that help you !
See you later :)
Marked as helpful1@devaramnyePosted about 1 year agoThank you really much. I will work on this project again to complete this one correctly. @DoctorLoo
1@okeke-ugochukwuPosted about 1 year ago@devaramnye
What you did wasn't wrong. From my perspective I see some impressive dom manipulation, Kudos!
At the same time, it I won't say it's the best approach. It's easier to just create the confirmation message as a separate entity and hide it by default, then display it when you need it.
Great work👍
Marked as helpful1
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