Design comparison
Solution retrospective
Is there a way to prevent the submission if a user does not click on a number? For now, I just let the default rating to be one.
Community feedback
- @EcePJDPosted over 1 year ago
You can disable the button using the 'disabled' attribute
You can use this js code to add disabled attribute: document.getElementById("submitButtonId").disabled = true;
And add an event listener function that detects the selection change of the selected option value (the rating 1 - 5). Inside that function add a condition that if the value is higher than 0 ( or any condition you know that is better that what i say :) ) it sets the disabled attribute to false: document.getElementById("submitButtonId").disabled = false;
Reference:
(disabled attribute) https://www.w3schools.com/tags/att_disabled.asp
(onchange event listener)https://www.w3schools.com/jsref/event_onchange.asp
Marked as helpful0
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