Class TextValidation
Stay organized with collections
Save and categorize content based on your preferences.
Spark icon
AI-generated Key Takeaways
-
TextValidation is a DataValidation specifically for TextItems in Google Forms.
-
It can be used to set validation rules for text input, such as requiring a number within a specific range.
-
You can customize the help text shown to the user when the input is invalid.
-
TextValidation objects are created using
FormApp.createTextValidation()
and applied to a TextItem usingsetValidation()
.
TextValidation
A DataValidation for a Text
.
// Add a text item to a form and require it to be a number within a range. constform=FormApp.create('My form'); consttextItem= form.addTextItem().setTitle('Pick a number between 1 and 100?'); consttextValidation= FormApp.createTextValidation() .setHelpText('Input was not a number between 1 and 100.') .requireNumberBetween(1,100) .build(); textItem.setValidation(textValidation);