Find all radio groups which haven't been selected

Posted by nickf on Stack Overflow See other posts from Stack Overflow or by nickf
Published on 2008-10-30T03:49:28Z Indexed on 2010/05/18 23:50 UTC
Read the original article Hit count: 161

Filed under:
|

I have a basic quiz/survey type application I'm working on, and I'd like to give the user a prompt before they submit if they haven't answered all the questions. All the questions are multiple choice using radio buttons:

<div class="question">
    Q1: What is the second letter of the alphabet?
    <div class="choices">
        <input type="radio" name="question_1" value="1" /> A
        <input type="radio" name="question_1" value="2" /> B
        <input type="radio" name="question_1" value="3" /> C
    </div>
</div>
<div class="question">
    Q2: Which out of these is a berry?
    <div class="choices">
        <input type="radio" name="question_2" value="1" /> Apples
        <input type="radio" name="question_2" value="2" /> Bananas
        <input type="radio" name="question_2" value="3" /> Carrots
    </div>
</div>
<div class="question"> ...etc

How do you find which groups haven't got an option ticked? Or at least, if there are any which haven't been answered?

jQuery is ok, and even preferred.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery