views:

82

answers:

1

Hi,

I'm using the jquery code below to validate a form. Now it all works great but I would like for the checkbox validation to use the '.validator' rather than its current 'alert', but when I add 'required="required"' to the checkbox input boxes, I get messages for all of the checkboxes, whereas I only need one. Hope this makes sense. Thanks in advance. S

$("#request-form").validator({
message: '<div><em/></div>',
position: 'top left',
offset: [3, 40]
});

$("#see").overlay({mask: '#999', fixed: false}).bind("onBeforeClose", function(e) {
$(".error").hide();
});

$('#request-form').submit(function(){
if(!$('#request-form input[type="checkbox"]').is(':checked')){
  alert("Please check at least one.");
  return false;
}
});
A: 

extrapaled from jquery validator not sure if this is will work with what your using because I've never heard of if I just use straight up jQuery

$("#request-form").validate({
    rules: {
        checkbox: { 
        required: 'input[type="checkbox"]:checked',
        minlength: $('input[type="checkbox"]').length();
        }
    },
    messages: {
        checkbox: "Please check at least one.",
    }
});

HTH

mcgrailm