Introduction:
Many time we need to limit the selection of checkboxes users can select
or in other words users are not allowed to select more than a number of
checkbox to give their choice. For example, out of all client side
script language, user can select maximum three where he is best.
As for example, take a look at below HTML checkboxlist
HTML:
jQuery JavaScript Prototype Dojo Mootools
JS:
$(document).ready(function () { $("input[name='tech']").change(function () { var maxAllowed = 2; var cnt = $("input[name='tech']:checked").length; if (cnt > maxAllowed) { $(this).prop("checked", ""); alert('Select maximum ' + maxAllowed + ' technologies!'); } }); });
0 comments :
Post a Comment