jeudi 2 avril 2015

validation of multiple check boxes for returned array in query

I'm trying to check proper number of check boxes for a question that are selected.


jQuery script is:



$.validator.addMethod("q3", function(value, elem, param) {
if($(".q3:checkbox:checked").length > 3){
return true;
}
else
{
return false;
}
}, "You must select at least 4!");


and on the actual input I have:



<input class='{roles: true}' type="checkbox" name="q3[]" value="a"/>


Am I in left field with this or missing something simple?





Aucun commentaire:

Enregistrer un commentaire