What would be the best way to loop through all radio buttons on my page and alert the user if one of them is unchecked for a particular question?
Note: there are multiple questions on one page.
<li>
<fieldset>
<h3>What music do you listen to?</h3>
<ul class="answerList">
<li>
<input type="radio" id="choice_22" name="answer8" value="1" class=""/>
<label for="choice_22" class="">Heavy Metal </label>
</li>
<li>
<input type="radio" id="choice_23" name="answer8" value="2" class=""/>
<label for="choice_23" class="">Pop music</label>
</li>
<li>
<input type="radio" id="choice_24" name="answer8" value="3" class=""/>
<label for="choice_24" class="">Oh, a mix of stuff </label>
</li>
</ul>
</fieldset>
</li>
if (undefined === $("input[name='answer8']:checked").val()) {
// do something
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With