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.
Please note: checkbox()
validation should be applied to checkbox groups with attribute sf-checkbox-group
.
Read more about Checkbox Groups here.
HTML Example
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)
.
Dos and Don'ts
Do ✅
checkbox(2, 10)
checkbox(2)
Don't ❌
checkbox(any, 10)
: Don't use alphabetic characters as arguments; only numbers are allowed.checkbox(2 , 5)
: Don't use spaces.checkbox(1, 2, 3)
: Don't use more than 2 arguments.
Last updated