@Rioba-IanSubmitted about 2 years ago
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?
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?
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 nothing