I am dynamically appending input fields to div
. I wish to check if at least one checkbox
is checked, for that I am adding JQuery
validation rule dynamically to the array of input checkbox
by using class. HTML:
<input type="checkbox" name="ans[]" value="opt_' + x + '" class="answer_check">
JavaScript:
$(".answer_check").rules("add", {required: true, messages: {required: "Please select correct answer/s."}});
I am getting following error in console.
Syntax error, unrecognized expression: label[for='ans[]'], label[for='ans[]'] *, #ans[]-error
Aucun commentaire:
Enregistrer un commentaire