checkbox()
Ensure proper number of checkboxes selected.
Setup
Attribute: sf-validation="checkbox(MIN_NUM, MAX_NUM)"
Where: Checkbox Group
Ensures that a specific range of checkboxes are selected within a group. This is useful for forms where users must make a certain number of selections, such as surveys or multi-select options.
HTML Example
<!-- Example with at least 2 checkboxes and a maximum of 4 checkboxes -->
<div sf-checkbox-group="someOptions" sf-validation="checkbox(2, 4)">
<input type="checkbox" name="option1"> Option 1<br>
<input type="checkbox" name="option2"> Option 2<br>
<input type="checkbox" name="option3"> Option 3<br>
<input type="checkbox" name="option4"> Option 4<br>
<input type="checkbox" name="option5"> Option 5<br>
<input type="checkbox" name="option6"> Option 6<br>
</div>
Webflow Example
→ You can also see it live here.
Usage Examples
checkbox(0,10)
: Requires at least 0 checkboxes to be selected, and allows up to 10 checkboxes to be selected.checkbox(2)
: Requires at least 2 checkboxes to be selected, with no restriction on the maximum number of selections.checkbox(3,3)
: Requires exactly 3 checkboxes to be selected.
Attribute Configuration
Make sure to add the sf-validation="checkbox(MIN_NUM,MAX_NUM)"
attribute to valid checkbox groups as mentioned above. Here are some instructions to keep in mind:
The attribute value should follow the format
checkbox(MIN_NUM,MAX_NUM)
orcheckbox(MIN_NUM)
.
Last updated
Was this helpful?