Something like this should work: function checkRadio() { var checked = false; $('input.amount').each(function() { if ($(this).is(':checked')) { checked = true; return false; } }); return checked; }
Inside your each function, you are querying for new input elements, instead of checking the current element. Also, your checkRadio() function isn't returning a result. Two other notes: 1) Your radio buttons should be grouped by name, so you should be able to use $('input[name="amount"]) instead of assigning a class to them. 2) The validation plugin should handle this already just by using {required: true} On Nov 1, 11:56 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi There, > I could use some jquery help here. This probably something very > simple that I'm missing. I started using jquery a few weeks ago so > please bear with me. > > In a nut shell, when a user submits the form (form id="register"), I > want it check to make sure they have selected a radio button > (class="amount"). If they forgot, I want it turn the #billing id (<h2 > id="billing>) red. I have server side validation working using PHP. > This is more of a visual indicator. I'm using the validate.js plug-in > and jquery 1.2.1. Any help would be great! > > $(document).ready(function() { > $("#register").submit( function() { > checkRadio(); > }); > > function checkRadio() { > $('input.amount').each(function() { > if ($('input:unchecked')) { > $("#billing").css('color', '#658300').show(); > return true; > } else { > $("#billing").css('color', '#C60006').show(); > return false; > } > }); > //close function > }; > > });