Skip to content

Limiting Selections in Team Forms

Team Forms offers powerful validation features to ensure that the information entered is well-formatted before submission. This helps prevent incorrect data entries and eliminates the need for back-and-forth communication requesting users to correct issues. One useful validation feature allows you to restrict the number of selections allowed in a component. However, how you apply this validation depends on the specific component. This article covers some common examples.

When the File component is configured to allow multiple files, you may still want to limit the total number of files a user can upload. To enforce this restriction:

  1. Navigate to the Validation tab of the File component.

  2. Under Custom Validation, include the following JavaScript check. Since the File component stores uploaded files in an array, you can use the array’s length to validate the response:

valid = instance.getValue().length < 5;

This validation ensures that users cannot upload more than four files.

When a Drop-down menu (or even a SharePoint Drop-down) is configured to allow multiple selections, users can select any number of items from the list. However, you may want to limit the total number of selections. To do this:

  1. Navigate to the Validation tab of the Drop-down menu or SharePoint data component.

  2. Under Custom Validation, enter the following JavaScript check. When Allow Multiple is enabled, Team Forms stores each selection in an array, allowing you to validate its length:

valid = instance.getValue().length < 5;

This ensures that users cannot select more than four options.

A Select Box displays multiple checkboxes, allowing users to select multiple options. To restrict the number of selections:

  1. Navigate to the Component Settings for the Select Box.

  2. Go to the Validation tab.

  3. Set the Maximum checked number and Minimum checked number options to define the allowed range of selections.

This method provides an easy way to control the number of selections without requiring custom validation scripts.