Use Case: Require a Maximum Number of Checkboxes 


In this Article
Related Articles

Introduction

There may be times when it is useful to limit the number a checkboxes a respondent can check. Maybe you want to have 10 possibilities in a checkbox field, but you only want respondents to check a maximum of 5.

Prior to setting up this use case, you should have a basic knowledge of form building and calculations.

Please Note: This use case uses custom code which our Support Team is unable to assist in writing or editing. You can reach out to our team about the code referenced in this documentation. However, any editing or changes in the code will not be supported if issues occur.


Prepare Your Form

  1. Create your checkbox field in your form. 
  2. Label and add choices to your checkbox field. 
  3. Select your checkbox field and click Options > Calculations > This is a variable. 
  4. Choose a name for the variable. For this example, we'll use "total". 
  5. Assign a value of "1" for each option.
  6. Add a Text Input Field to your form. Give it any label. For this example, the label is "Error".
  7. Select the Text Input Field and click Options > Default Value and set the value for this field to "You may only choose 2 options".
  8. Next, scroll down in the Options menu for the Error field and click Calculations > This is a variable. 
  9. Choose a name for this variable. For this example, we chose "error". 
  10. Scroll down in the Options menu for the Error field and set the Access Control to "Hidden".
  11. Add a new Text Input Field to your form. Give it any label. For this example, the label is "Checkbox Calculation".
  12. Select the Checkbox Calculation field and click Options > Presentation > Label Placement > Remove Label.
  13. Scroll down in the Options menu and click Calculations > This is a calculated field.
  14. Enter the following formula with your own variables: 
    total>2?error:""
  15. Scroll up in the Options menu and click Validation Rules > Expected Input Format > Custom.
  16. Under "Validate with a Regular Expression" enter the following:
    /^$/
  17. Your validation should look like this:
  18. Save your form.
  19. Test your new setup by clicking View and then testing in the live form. 
Terms of Service · Privacy Policy