Hello,
Please use this code as below..
<input type="checkbox" name="chkName" id="chkName" value="1" />
<input type="checkbox" name="chkName" id="chkName1" value="2" />
<input type="checkbox" name="chkName" id="chkName2" value="3" />
<input type="checkbox" name="chkName" id="chkName3" value="4" />
<input type="checkbox" name="chkName" id="chkName4" value="5" />
<input type="checkbox" name="chkName" id="chkName5" value="6" />
<input type="checkbox" name="chkName" id="chkName6" value="7" />
<input type="checkbox" name="chkName" id="chkName7" value="8" />
<input type="checkbox" name="chkName" id="chkName8" value="9" />
<input type="checkbox" name="chkName" id="chkName9" value="10" />
<input type="checkbox" name="chkName" id="chkName10" value="11" />
<input type="checkbox" name="chkName" id="chkName11" value="12" />
<input type="checkbox" name="chkName" id="chkName12" value="13" />
<input type="button" name="btnSave" value="Save" onclick="return CheckValid();" />
And..
<script type="text/javascript">
var arIntIds = new Array();
var counter = 1;
$(function () {
$("input[id^='chkName']").change(function () { CheckUnCheckAll(this); });
});
function CheckUnCheckAll(chk) {
if ($(chk).is(':checked')) {
PushToIntIds(counter);
}
else {
PullFromIntIds(counter);
}
}
function PushToIntIds(counter) {
arIntIds.push(counter);
alert("Selected Checkbox Count : " + arIntIds.length);
}
function PullFromIntIds(counter) {
arIntIds.pop(counter);
alert("Selected Checkbox Count : " + arIntIds.length);
}
function CheckValid() {
if (arIntIds.length >= 10) {
alert("You can not select more then 10 checkbox!!");
return;
}
else {
alert('Move on ..');
}
}
</script></script>