Multiple Checkbox validation in asp.net mvc 3 using jquery:
This is the sample code for select only one check box from a check box group.
function ValidateChkBox()
{
var selectedCheckBoxesValue = '';
$('#DIVID').find("input:checkbox.CheckBoxClassName:checked").each(function (i, selected) {
if (selectedCheckBoxesValue.length == 0) {
selectedCheckBoxesValue += $(selected).val();
}
else {
selectedCheckBoxesValue += ',' + $(selected).val();
}});
// Here you also get all the comma separated values if you want else use below method for it
if(selectedCheckBoxesValue.length == 0)
{
alert("Select atleast one checkbox");
}
}







0 comments:
Post a Comment
Share your thoughts here...