//Addatextitemtoaformandrequireittobeanumberwithinarange.vartextItem=form.addTextItem().setTitle('Pick a number between 1 and 100?');vartextValidation=FormApp.createTextValidation().setHelpText(“Inputwasnotanumberbetween1and100.”).requireNumberBetween(1,100).build();textItem.setValidation(textValidation);
[[["易于理解","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\u003eDataValidationBuilder\u003c/code\u003e facilitates the creation of data validation rules for form items, like ensuring a text input is a number within a specific range.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods to set help text, which is displayed if validation fails, and ultimately builds a \u003ccode\u003eDataValidation\u003c/code\u003e object applied to the form item.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can utilize methods such as \u003ccode\u003erequireNumberBetween()\u003c/code\u003e to define specific validation criteria, and chain methods for streamlined implementation.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ebuild()\u003c/code\u003e method finalizes the validation setup, generating a \u003ccode\u003eDataValidation\u003c/code\u003e object ready to be associated with a form item for enforcing data integrity.\u003c/p\u003e\n"]]],["`DataValidationBuilder` constructs `DataValidation` objects, allowing the setting of common validation properties like help text. The `build()` method finalizes the `DataValidation` object. `copy()` duplicates the builder. `setHelpText(text)` assigns instructional text displayed when input is invalid. As illustrated, a text item can be set to only accept numbers within a defined range, displaying help text for incorrect input. This process creates validations in forms.\n"],null,[]]