// 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);
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-11-26 UTC."],[[["`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()`."]]],[]]