Class TextValidation
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
การตรวจสอบข้อความ
DataValidation สำหรับ TextItem
// Add a text item to a form and require it to be a number within a range.
const form = FormApp.create('My form');
const textItem =
form.addTextItem().setTitle('Pick a number between 1 and 100?');
const textValidation =
FormApp.createTextValidation()
.setHelpText('Input was not a number between 1 and 100.')
.requireNumberBetween(1, 100)
.build();
textItem.setValidation(textValidation);
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[[["\u003cp\u003e\u003ccode\u003eTextValidation\u003c/code\u003e is used to apply specific data validation rules to text-based form responses collected through a \u003ccode\u003eTextItem\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eIt enables defining criteria like number ranges, custom error messages (using \u003ccode\u003esetHelpText\u003c/code\u003e), and applying these constraints via \u003ccode\u003esetValidation\u003c/code\u003e on the target \u003ccode\u003eTextItem\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe example demonstrates setting a numeric constraint, requiring user input to fall between 1 and 100 with a clear error message if the input is invalid.\u003c/p\u003e\n"]]],[],null,["# Class TextValidation\n\nTextValidation\n\nA DataValidation for a [TextItem](/apps-script/reference/forms/text-item).\n\n```javascript\n// Add a text item to a form and require it to be a number within a range.\nconst form = FormApp.create('My form');\nconst textItem =\n form.addTextItem().setTitle('Pick a number between 1 and 100?');\nconst textValidation =\n FormApp.createTextValidation()\n .setHelpText('Input was not a number between 1 and 100.')\n .requireNumberBetween(1, 100)\n .build();\ntextItem.setValidation(textValidation);\n```"]]