// Add a checkbox grid item to a form and require one response per column.constform=FormApp.openById('123abc');constcheckboxGridItem=form.addCheckboxGridItem();checkboxGridItem.setTitle('Where did you celebrate New Years?').setRows(['New York','San Francisco','London']).setColumns(['2014','2015','2016','2017']);constcheckboxGridValidation=FormApp.createCheckboxGridValidation().setHelpText('Select one item per column.').requireLimitOneResponsePerColumn().build();checkboxGridItem.setValidation(checkboxGridValidation);
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003e\u003ccode\u003eCheckboxGridValidation\u003c/code\u003e is used to set validation rules specifically for \u003ccode\u003eCheckboxGridItem\u003c/code\u003e within Google Forms.\u003c/p\u003e\n"],["\u003cp\u003eIt allows you to enforce constraints like requiring exactly one response per column in a checkbox grid, enhancing data integrity and user experience.\u003c/p\u003e\n"],["\u003cp\u003eYou can customize the validation with help text to guide users on expected input.\u003c/p\u003e\n"]]],["This content demonstrates creating and validating a checkbox grid item within a form. It outlines adding a checkbox grid with titles, rows (e.g., \"New York\"), and columns (e.g., \"2014\"). The example then builds a `CheckboxGridValidation` to enforce a limit of one response per column, including setting custom help text. Finally, it applies this validation to the checkbox grid, ensuring responses adhere to the set criteria.\n"],null,["# Class CheckboxGridValidation\n\nCheckboxGridValidation\n\nA DataValidation for a [CheckboxGridItem](/apps-script/reference/forms/checkbox-grid-item).\n\n```javascript\n// Add a checkbox grid item to a form and require one response per column.\nconst form = FormApp.openById('123abc');\nconst checkboxGridItem = form.addCheckboxGridItem();\ncheckboxGridItem.setTitle('Where did you celebrate New Years?')\n .setRows(['New York', 'San Francisco', 'London'])\n .setColumns(['2014', '2015', '2016', '2017']);\nconst checkboxGridValidation = FormApp.createCheckboxGridValidation()\n .setHelpText('Select one item per column.')\n .requireLimitOneResponsePerColumn()\n .build();\ncheckboxGridItem.setValidation(checkboxGridValidation);\n```"]]