mardi 19 janvier 2016

Limit checkbox selection in SharePoint Online Survey

I've been pulling my hair out trying to find a solution to this problem! I have a SharePoint Online Survey, that contains five questions where the respondent can check up to six checkboxes per question. However, for two of those questions, I need to limit the number of boxes a user can check, to three. The code below will limit every checkbox in the survey to three selections, and I can't figure out how to target just the two questions that need to restrict to three boxes. Any help would be greatly appreciated!!

jQuery(function(){
var max = 3;
var checkboxes = $('input[type="checkbox"]');

checkboxes.change(function(){
    var current = checkboxes.filter(':checked').length;
    checkboxes.filter(':not(:checked)').prop('disabled', current >= max);
});

});




Aucun commentaire:

Enregistrer un commentaire