适用于 CheckboxValidation 的 DataValidationBuilder。
// Add a checkBox item to a form and require exactly two selections. const form = FormApp.create('My Form'); const checkBoxItem = 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'), ]); const checkBoxValidation = FormApp.createCheckboxValidation() .setHelpText('Select two condiments.') .requireSelectExactly(2) .build(); checkBoxItem.setValidation(checkBoxValidation);
方法
| 方法 | 返回类型 | 简介 |
|---|---|---|
require | Checkbox | 要求至少选择这么多选项。 |
require | Checkbox | 要求最多选择这么多选项。 |
require | Checkbox | 要求选择的选项数量必须正好是此值。 |
详细文档
requireSelectAtLeast(number)
要求至少选择这么多选项。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
number | Integer |
返回
CheckboxValidationBuilder - 此 CheckboxValidationBuilder,用于链式调用
requireSelectAtMost(number)
要求最多选择这么多选项。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
number | Integer |
返回
CheckboxValidationBuilder - 此 CheckboxValidationBuilder,用于链式调用
requireSelectExactly(number)
要求选择的选项数量必须正好是此值。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
number | Integer |
返回
CheckboxValidationBuilder - 此 CheckboxValidationBuilder,用于链式调用