Hello there, I could really use some assistance with the JavaScript part of this code. I have two JavaScript functions: one for validating if a radio checkbox is selected, and another for revealing the "answer". Currently, an alert pops up if no selections are made (which is good), but then the answer remains unrevealed regardless of the selection.
My ideal scenario would be for the "answer" to only be revealed if at least one checkbox is selected; otherwise, if nothing is selected, an alert should be triggered on the page.
Below are the two JavaScript functions:
<script>
document.getElementById("answer").style.display ="none";
function validateForm() {
var choices = document.getElementsByName("Question");
for(var i = 0; i < choices.length; i++) {
if(!(choices[i].checked)){
alert("Please select an answer choice");
return false;
}
}
}
function openTest() {
document.getElementById("answer").style.display = "block";
}
document.getElementById('button').addEventListener('click', openTest);
</script>