Checkbox 的 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 | 要求必须选择此数量的选项。 | 
详细文档
require
要求至少选择此数量的选项。
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| number | Integer | 
返回
Checkbox - 此 Checkbox,用于链式调用
require
最多可选择此数量的选项。
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| number | Integer | 
返回
Checkbox - 此 Checkbox,用于链式调用
require
要求必须选择此数量的选项。
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| number | Integer | 
返回
Checkbox - 此 Checkbox,用于链式调用