Using jQuery to check if one in set of radio buttons is checked

codeadventurer

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?

Arun P Johny

Try

$('tr').not(':has(:radio:checked)').addClass("ERROR");

Demo: Fiddle

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Check if one of the radio buttons within a div is checked

From Dev

Checked Radio Buttons ID using Jquery change

From Dev

Using jQuery to check if radio button is not checked

From Dev

Using jQuery to check if radio button is not checked

From Dev

Set radio buttons group checked

From Dev

Check if radio buttons are set

From Dev

jQuery: Radio buttons not getting checked

From Dev

Jquery check if radio button is checked

From Dev

How do i check if a specific Radio button is checked among the other radio buttons using Javascript?

From Dev

Jquery - Iterate through all checked radio buttons

From Dev

Multiple radio buttons are being checked in JQuery Mobile

From Dev

How to get the radio buttons that are NOT checked (Jquery)?

From Dev

How to set checked radio button using name and attr in jquery?

From Dev

JQuery - check if all radio buttons are "No"

From Dev

How to check the values of multiple dynamic radio buttons in a form using jquery

From Dev

jQuery: Check and listen if radio button is checked

From Dev

Checked to see if radio buttons are checked

From Dev

Radio buttons are checked simultaneously

From Dev

How to check if any of the Radio buttons are checked or not when clicked on submit button

From Dev

Check if two radio buttons checked, then write. [HTML/JS]

From Dev

How do I check which radio button is selected when there are multiple radio buttons with the same name? (using jquery)

From Dev

how to uncheck a group of radio buttons when one in another group is checked

From Dev

How to set radio buttons in custom meta box checked?

From Dev

How to set hidden field to zero if radio buttons are not checked

From Dev

How to set radio buttons in custom meta box checked?

From Dev

jQuery check value of multiple radio buttons

From Dev

How to check the multiple indicdual radio buttons in jQuery?

From Dev

Jquery .val() function to check the value of radio buttons

From Dev

Set radio buttons by value using jquery on non-checkboxradio object (buttons behave differently with css)

Related Related

  1. 1

    Check if one of the radio buttons within a div is checked

  2. 2

    Checked Radio Buttons ID using Jquery change

  3. 3

    Using jQuery to check if radio button is not checked

  4. 4

    Using jQuery to check if radio button is not checked

  5. 5

    Set radio buttons group checked

  6. 6

    Check if radio buttons are set

  7. 7

    jQuery: Radio buttons not getting checked

  8. 8

    Jquery check if radio button is checked

  9. 9

    How do i check if a specific Radio button is checked among the other radio buttons using Javascript?

  10. 10

    Jquery - Iterate through all checked radio buttons

  11. 11

    Multiple radio buttons are being checked in JQuery Mobile

  12. 12

    How to get the radio buttons that are NOT checked (Jquery)?

  13. 13

    How to set checked radio button using name and attr in jquery?

  14. 14

    JQuery - check if all radio buttons are "No"

  15. 15

    How to check the values of multiple dynamic radio buttons in a form using jquery

  16. 16

    jQuery: Check and listen if radio button is checked

  17. 17

    Checked to see if radio buttons are checked

  18. 18

    Radio buttons are checked simultaneously

  19. 19

    How to check if any of the Radio buttons are checked or not when clicked on submit button

  20. 20

    Check if two radio buttons checked, then write. [HTML/JS]

  21. 21

    How do I check which radio button is selected when there are multiple radio buttons with the same name? (using jquery)

  22. 22

    how to uncheck a group of radio buttons when one in another group is checked

  23. 23

    How to set radio buttons in custom meta box checked?

  24. 24

    How to set hidden field to zero if radio buttons are not checked

  25. 25

    How to set radio buttons in custom meta box checked?

  26. 26

    jQuery check value of multiple radio buttons

  27. 27

    How to check the multiple indicdual radio buttons in jQuery?

  28. 28

    Jquery .val() function to check the value of radio buttons

  29. 29

    Set radio buttons by value using jquery on non-checkboxradio object (buttons behave differently with css)

HotTag

Archive