Class CheckboxValidation

Checkbox Validation

A DataValidation for a Checkbox Item .

 // 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 
 ); 
Create a Mobile Website
View Site in Mobile | Classic
Share by: