Superform by Delta Clan
✨ ClonablesSocialResourcesSuperform Home
v2
v2
  • 🏁Getting Started
    • Introduction
    • Quick Start
  • 🫀Essentials
    • Form Container
    • Step Container
    • Navigation - Overview
      • Direct
      • Logic / Conditional
      • Hook
    • Variables
      • Form Data ($f)
      • Step Index ($s)
      • Progress Percentage ($p)
      • Scoring Variables ($v)
    • Progress Bar
    • Reset
    • Radio Groups
    • Checkbox Groups
    • Cheatsheet
  • ⚙️Global Options
    • Step Delay Controls
    • Animations
      • Step Animation
      • Step Animation Duration
      • Step Animation Ease
    • Save Data & Progress
    • Pre-fill Form
    • Prevent Content Flash
    • Debug
    • Third-party Integrations
    • Cheatsheet
  • 🎛️Input Validation & Errors
    • Validation
      • length()
      • words()
      • minmax()
      • checkbox()
      • must()
      • hook()
    • Error Management
      • Automatic Error Setup
      • Manual Error Setup
  • ⚡Reactivity
    • Update Text
    • Visibility
    • Class Toggle
    • Value
    • Set Attribute
  • 🔢Score Tracking
    • Score Setup & Calculation
    • Score Ranking
  • ⌨️Accessibility
    • Enter & Backspace Bindings (↩, ⌫)
    • Checkbox & Radio Bindings
  • 🛠️Javascript SDK
    • Intro to Superform API
    • Superform Instance
    • Cheatsheet
  • 📖Additional Resources
    • WTF is an expression ? 🆕
    • Integrations
    • Tutorials
    • Changelog
    • FAQ 🚧
    • Join Discord
Powered by GitBook
On this page
  • Setup
  • Usage Examples
  • Attribute Configuration

Was this helpful?

  1. Input Validation & Errors
  2. Validation

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

index.html
<!-- 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


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) or checkbox(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 9 months ago

Was this helpful?

→ You can also see it live .

🎛️
here
Video example how to setup checkbox() validation.
Setting the checkbox() validation attribute to the checkbox group.