In the code below the function which must determine whether the field is required does not work. The code relates to a website for which some text fields ('person_item') and checkboxes ('chckbox') are created dynamiccally followed by adding the validation rule. If the checkbox of a set is selected, the related 'person_item' textfield must be validated (else not).
I think I understand why the function for 'required' does not work (because of 'nr', but I dont know how to write the correct code).(PS: the validation rule does work with respect to the 'maxlength' and 'float' validation types)
for(var nr=0;nr<maxitems;nr++){
form = getSingleform(nr,type);
$("#wrapper").append(form);
$("#person_item"+nr).rules("add", {
required: function(element) {return ($('#chckbox'+nr).is(':checked') ); },
maxlength: 3,
float:true,
}); //rules add
}//for