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:
- //ckeck if inputs aren't empty
- var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
- var fields = $('#first_step input[type=text]');
- var error = 0;
- fields.each(function(){
- var value = $(this).val();
- if( value.length<1 || value==field_values[$(this).attr('id')] || ( $(this).attr('id')=='email' && !emailPattern.test(value) ) ) {
- $(this).addClass('error');
-
- error++;
- } else {
- $(this).addClass('valid');
- }
- });
-
- if(!error) {
Really appreciate your help!
greets.