Ever wanted to check if a user has checked at least one option from a series of radio fields? JQuery makes this super simple, here's how to do it:
Our html page contains a series of radio input fields and I want to make sure that the user has selected either 'Yes' or 'No' for each option. I know that there are thirteen radio fields, so using the JQuery selector below we can select and count the number of checked fields. If it doesn't match the total then we know the user has left something unchecked.
var n = $("input:checked").length;
if(n == 13)
// not enough options selected
alert('Please select Yes or No for each option');
I am using a button with a class of 'continue-button' to trigger the function.
JQuery selectors can be amazing powerful, read on them here: http://api.jquery.com/category/selectors/