jeudi 9 novembre 2017

Select multiple checkboxes in multi categories jQuery

I'm trying to configure multiple checkboxes with jQuery,

I want User can select 8 checkboxes max inside 2 different categories max.

Currently User can select 8 checkboxes but I don't how to restrict to 2 categories.

$(document).ready(function () {
    $("input[name='tech']").change(function () {
        var maxAllowed = 8;
        var cnt = $("input[name='tech']:checked").length;
        if (cnt > maxAllowed) {
            $(this).prop("checked", "");
            alert('You can select maximum ' + maxAllowed + ' technologies!!');
        }
    });
});

Full code example: http://ift.tt/2hfNU4O

Any idea?




Aucun commentaire:

Enregistrer un commentaire