Check radio button with jquery?

Check radio button with jquery?

Hi there,

I am totally new to jquery and did manage to design a form and check fields on values (with a little help;)). Now i also have 2 radio button options, and at least 1 need to be checked. So i would like to validate this too before the form will be sent.

Here is my validation now, without the radio funtion:
  1. //ckeck if inputs aren't empty
  2. var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;  
  3.         var fields = $('#first_step input[type=text]');
  4.         var error = 0;
  5.         fields.each(function(){
  6.             var value = $(this).val();
  7.               if( value.length<1 || value==field_values[$(this).attr('id')] || ( $(this).attr('id')=='email' && !emailPattern.test(value) ) ) {
  8.                 $(this).addClass('error');
  9.                                 
  10.                 error++;
  11.             } else {
  12.                 $(this).addClass('valid');
  13.             }
  14.         });        
  15.         
  16.         if(!error) {


Really appreciate your help!
greets.