Design comparison
Solution retrospective
Unfortunately I had a problem when I wanted to prevent the the procedure if there was no number been selected, Any ideas ?
Community feedback
- Account deleted
Hi!
First of all - very well made solution, congrats! 😊
When it comes to your question, you can have a look at my solution for this project.
I placed a conditional statement inside of a for each loop that went through all of the grades. If none of the elements contained an 'active' class (I used it to add the background color and 'choose' the element), an error would appear and the card would not switch to the thank you page.
Hope you find it helpful!
Marked as helpful1@ASH2001princePosted about 2 years ago@jsabram you did a great job on your project, and I have learned a lot form it :)
0 - @AhmedLebdaPosted about 2 years ago
to prevent submitting the rate if the user didn't choose a rate, you can simply add a condition in your event handler for the submit button event, for example :
btn.addEventListener("click", () => { if(!finalValue) { return false } else { valueS.textContent = finalValue; secondCard.style.display = "flex"; firstCard.style.display = "none"; } });
The condition means if the user didn't choose a rate so the
finalValue
variable is equal toundefined
(undefined values === false) the function will just return false otherwise the button submits the rate (when user choose a rate)Marked as helpful0@ASH2001princePosted about 2 years ago@AhmedLebda actually that worked so good, thank you bro
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