Class DataValidation
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
数据验证
包含所有验证通用的属性(例如帮助文本)的基准 DataValidation。
您可以向某些 Form
项添加验证。
// Add a text item to a form and require it to be a number within a range.
var textItem = form.addTextItem().setTitle('Pick a number between 1 and 100?');
var textValidation = FormApp.createTextValidation()
.setHelpText(“Input was not a number between 1 and 100.”)
.requireNumberBetween(1, 100);
textItem.setValidation(textValidation);
详细文档
getHelpText()
获取 DataValidation 的帮助文本。如果输入内容验证失败,系统会向用户显示此文本。
返回
String
- DataValidation 的帮助文本
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003eDataValidation objects define requirements for user input in Google Forms, such as specific data types or value ranges.\u003c/p\u003e\n"],["\u003cp\u003eThese validations can be applied to form items like text fields to ensure data integrity and guide user responses.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003egetHelpText()\u003c/code\u003e retrieves the message displayed to the user when input fails validation, aiding in understanding errors.\u003c/p\u003e\n"]]],[],null,["# Class DataValidation\n\nDataValidation\n\nThe base DataValidation that contains properties common to all validations, such as help text.\nValidations can be added to certain [Form](/apps-script/reference/forms/form) items.\n\n```gdscript\n // Add a text item to a form and require it to be a number within a range.\n var textItem = form.addTextItem().setTitle('Pick a number between 1 and 100?');\n var textValidation = FormApp.createTextValidation()\n .setHelpText(“Input was not a number between 1 and 100.”)\n .requireNumberBetween(1, 100);\n textItem.setValidation(textValidation);\n \n``` \n\n### Methods\n\n| Method | Return type | Brief description |\n|---------------------------------|-------------|--------------------------------------|\n| [getHelpText()](#getHelpText()) | `String` | Gets the DataValidation's help text. |\n\nDetailed documentation\n----------------------\n\n### `get``Help``Text()`\n\nGets the DataValidation's help text. This text is shown to the user if the input fails\nvalidation.\n\n#### Return\n\n\n`String` --- the DataValidation's help text"]]