Design comparison
SolutionDesign
Solution retrospective
When a user submits the without selecting a rating, the button still submits but I don't want it to submit when there is nothing selected. How can I modify these changes in my js?
Community feedback
- @kyriakossdrPosted about 2 years ago
Hello my friend,
What you could is to modify your js to seem like this on line 36:
submitBtn.addEventListener('click', () => { if (answerValue !== '') { // same as answerValue != 0 scoreCard.style.display = 'none'; thankyou.style.display = 'flex'; storeAnswer(answerValue); } // console.log("it works"); });
What this does is to check if answerValue has changed from its initial value. If that is true means that the user selected an option, if not (the
answerValue === ''
//its initial value) means that the user selected nothingMarked as helpful1@Rioba-IanPosted about 2 years ago@K1riakos Just made the change and it worked. Thank you man!
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