Skip to content

choice

Validates that the number of selected checkboxes in a group is within a specified range.

Options

OptionTypeDefaultDescription
minnumberundefinedMinimum number of checkboxes that must be checked
maxnumberundefinedMaximum number of checkboxes that can be checked
messagestringlocale defaultCustom error message

Playground

Valid values

ValueNotes
2 checkboxes checkedWithin min=1, max=3
1 checkbox checkedEqual to min

Invalid values

ValueReason
0 checkboxes checkedBelow min=1
4 checkboxes checkedExceeds max=3

Notes

  • If no checkboxes are checked, choice counts 0 selected items. Set min: 1 or higher to require at least one selection.
  • Do not combine with notEmpty — it checks string values, not checkbox state.
  • Applies to groups of checkboxes sharing the same name attribute.

Released under the MIT License.