Class TextValidation Stay organized with collections Save and categorize content based on your preferences.
Page Summary
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 aText.
// 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);
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-11 UTC.