Validation Checkbox array using jquery

Posted: December 26, 2014 in Jquery Code

<input type="checkbox" name="services[]" >Text 1<br>
<input type="checkbox" name="services[]" >Text 2<br>
<input type="checkbox" name="services[]" >Text 3<br>



$("#submitted").click(function() { 
 if( $('input[name="services[]"]:checked').length == 0 )
 {
    $('#services').prop('required',true); //for html5 ...add required attributes
 }
 else 
 {
    $('#services').prop('required',false);
 }
 });
Advertisements

Comments are closed.