We've been able to limit multiselect checkboxes to two (out of six). But we have hidden fields that reveal when a box is checked and after checking two boxes, a third hidden field is revealed if the user happens to check a third box. We are trying to limit the hidden field reveals to only the boxes checked.
Here's the code. Any help would be much appreciated!
[js]
jQuery('ul#input_3_23 li input').click(function(){
if(jQuery(this).is(':checked')){
var curavaildata = jQuery(this).val();
hiddenvalue = hiddenvalue + curavaildata + ";";
}
else{
var curavaildata = jQuery(this).val();
curavaildata = curavaildata + ";";
hiddenvalue = hiddenvalue.replace(curavaildata,"");
}
jQuery('input#input_3_41').attr("value",hiddenvalue);
//Fill in the hidden field for the availability data
//check-box limit
$.fn.limit = function(n) {
var self = this;
this.click(function(){ return (self.filter(":checked").length<=n); });
}
$("ul#input_3_23 li input:checkbox").limit(2);
});