I have 10 options in a checkbox list, out of which i want to select limit selection to one option for the first 5 and 0-5 options for the next 5 choices. eg my options for a particular question are 0 1 2 3 4 a b c d e

user should be able to select only one checkbox for first 5 choices (0-4) and multiple selection for the rest (a-b)

1 Answers

0
Community On

My recommendation would be to separate 0-4 and a-b-c-d-e into different columns. The 0-4 can be Radio Buttons which allows only one selection and the a-b-c-d-e can be checkboxes that allow multiple selections.

If arent able to take this approach. You can use some hacky jquery to target the first 5 that you only want one selected on. Since its a default SharePoint form you will need to target based on the text

$(document).ready(function() {
   // array of names of 0-4
   var namesArray = ["name1", "name2"];
   // You would need to do something like this
   $("input[type='checkbox']").change(function() {
      // if name of $(this) is contained in array
      // grab the state of the other checkboxes whos names are in array
         // probably using a foreach and ifs
           // if another is checked uncheck it
   });
});

You would want to do something along those lines. Like I said kinda hacky but doable. I still stress breaking them into separate columns though.