Class CheckboxValidationBuilder Stay organized with collections Save and categorize content based on your preferences.
AI-generated Key Takeaways
CheckboxValidationBuilder is used to create validation rules for checkbox items in a form.
It allows you to require a specific number of choices to be selected using methods like
requireSelectAtLeast,requireSelectAtMost, andrequireSelectExactly.These methods take an integer as a parameter to specify the required number of selections.
A DataValidationBuilder for aCheckbox.
// Add a checkBox item to a form and require exactly two selections.constform=FormApp.create('My Form');constcheckBoxItem=form.addCheckboxItem();checkBoxItem.setTitle('What two condiments would you like on your hot dog?');checkBoxItem.setChoices([checkBoxItem.createChoice('Ketchup'),checkBoxItem.createChoice('Mustard'),checkBoxItem.createChoice('Relish'),]);constcheckBoxValidation=FormApp.createCheckboxValidation().setHelpText('Select two condiments.').requireSelectExactly(2).build();checkBoxItem.setValidation(checkBoxValidation);
Methods
| Method | Return type | Brief description |
|---|---|---|
require | Checkbox | Require at least this many choices to be selected. |
require | Checkbox | Require at most this many choices to be selected. |
require | Checkbox | Require exactly this many choices to be selected. |
Detailed documentation
requireSelectAtLeast(number)
Require at least this many choices to be selected.
Parameters
| Name | Type | Description |
|---|---|---|
number | Integer |
Return
Checkbox — thisCheckbox, for chaining
requireSelectAtMost(number)
Require at most this many choices to be selected.
Parameters
| Name | Type | Description |
|---|---|---|
number | Integer |
Return
Checkbox — thisCheckbox, for chaining
requireSelectExactly(number)
Require exactly this many choices to be selected.
Parameters
| Name | Type | Description |
|---|---|---|
number | Integer |
Return
Checkbox — thisCheckbox, for chaining
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-12-02 UTC.