Class CheckboxValidation
CheckboxValidation
CheckboxItem
的 DataValidation。
// Add a checkBox item to a form and require exactly two selections.
var 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')
]);
var checkBoxValidation = FormApp.createCheckboxValidation()
.setHelpText(“Select two condiments.”)
.requireSelectExactly(2)
.build();
checkBoxItem.setValidation(checkBoxValidation);
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-08-21。
[null,null,["最后更新时间 (UTC):2024-08-21。"],[[["`CheckboxValidation` is used to set validation rules specifically for checkbox items within Google Forms."],["It allows you to define requirements like the number of choices a user must select using methods like `requireSelectExactly()`."],["A help text can be associated with the validation to guide the user using `setHelpText()`."]]],[]]