I have a quiz set up in the following way:
A table on with the questions on the left, and True or False radio buttons on the right.
At the bottom of the quiz, I have a Step 2 button, which upon clicking, pulls up a Fancybox layer to ask the person's contact information in a form.
I'd like to stop the fancybox window from opening unless one answer is selected for each question (true, or false). If the user has not selected an answer, I'd like to display a message letting them know that an answer must be selected below the question(s) that have not been answered.
I've tried using this code onClick:
$("input:radio:not(:checked)").parent().parent().append("ERROR")
The only issue is that this code is not recognizing that their are pairs of radio buttons, not just individuals, and that it should only mark an error if neither of them are selected.
Below is a sample of my markup.
<tr class="alternate">
<td>At school, you have to reminded to do your assignments.</td>
<td class="centered"><input type="radio" class="radio" name="Question_1" value="True" /></td>
<td class="centered"><input type="radio" class="radio" name="Question_1" value="False" /></td>
</tr>
Any suggestions on how I can improve my jQuery to accomplush this?
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments