Class CheckboxValidationBuilder

  • CheckboxValidationBuilder allows you to set validation rules for checkbox items in Google Forms.

  • You can specify the minimum, maximum, or exact number of choices that must be selected.

  • Validation rules can be customized with help text to guide users.

  • It is used with CheckboxItem to create and manage checkbox questions within forms.

CheckboxValidationBuilder

A DataValidationBuilder for a CheckboxValidation.

// 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);

Methods

MethodReturn typeBrief description
requireSelectAtLeast(number)CheckboxValidationBuilderRequire at least this many choices to be selected.
requireSelectAtMost(number)CheckboxValidationBuilderRequire at most this many choices to be selected.
requireSelectExactly(number)CheckboxValidationBuilderRequire exactly this many choices to be selected.

Detailed documentation

requireSelectAtLeast(number)

Require at least this many choices to be selected.

Parameters

NameTypeDescription
numberInteger

Return

CheckboxValidationBuilder — this CheckboxValidationBuilder, for chaining


requireSelectAtMost(number)

Require at most this many choices to be selected.

Parameters

NameTypeDescription
numberInteger

Return

CheckboxValidationBuilder — this CheckboxValidationBuilder, for chaining


requireSelectExactly(number)

Require exactly this many choices to be selected.

Parameters

NameTypeDescription
numberInteger

Return

CheckboxValidationBuilder — this CheckboxValidationBuilder, for chaining