Can anyone suggest what mistake i did in following scripts so it is not able to validate the checkbox list
<script type ="text/javascript" >
$.validator.addMethod('SelectAtlistOne', function (value, element) {
if (debug) {
$.jGrowl("Adding Validation");
}
var chkGroup = $("input[id^=<%=ckSkills.UniqueID %>]");
if (chkGroup.length > 0) {
for (var i = 0; i < chkGroup.length; i++) {
if ($(chkGroup[i]).attr('checked')) {
if (debug) {
// alert(i + $(chkGroup[i]).val());
$.jGrowl("Running loop " + i + " = " + $(chkGroup[i]).val());
}
return true;
}
}
return false;
}
return false;
}, 'Please select at least one option');
$("#form1").validate({
rules: {
<%=ckSkills.UniqueID %>: {
SelectAtlistOne:true
}
}
}
});
});
</script>
Checkbox list is like
<asp:CheckBoxList ID="ckSkills" runat="server" RepeatDirection="Horizontal">
</asp:CheckBoxList>
This list is is binding in run time. Please suggest me what i need to modify to make this code executable. I don't want to add separate function for checkbox list and validate it.
Aucun commentaire:
Enregistrer un commentaire