يستقبل منشئ إدخال النص قيمة اختيارية ومدقّقًا اختياريًا. يجب أن يتم تحويل القيمة إلى سلسلة. إذا كانت القيمة null أو undefined، سيتم استخدام سلسلة فارغة.
يبدو رمز JSON الخاص بحقل إدخال نص على النحو التالي:
{"fields":{"FIELDNAME":"text"}}
حيث FIELDNAME هي سلسلة تشير إلى حقل إدخال نصي، والقيمة هي القيمة التي سيتم تطبيقها على الحقل. تخضع القيمة للقواعد نفسها التي تخضع لها قيمة الدالة الإنشائية.
XML
يبدو رمز XML الخاص بحقل إدخال النص على النحو التالي:
<fieldname="FIELDNAME">text</field>
عندما تحتوي السمة name للحقل على سلسلة تشير إلى حقل إدخال نصي، ويكون النص الداخلي هو القيمة التي سيتم تطبيقها على الحقل. تخضع قيمة النص الداخلي للقواعد نفسها التي تخضع لها قيمة أداة الإنشاء.
التخصيص
التدقيق الإملائي
يمكن استخدام الدالة
setSpellcheck
لتحديد ما إذا كان الحقل يصحّح إملائيًا النص الذي يتم إدخاله أم لا.
حقول إدخال النص مع التدقيق الإملائي وبدونه
تكون ميزة التدقيق الإملائي مفعَّلة تلقائيًا.
وينطبق ذلك على الحقول الفردية. إذا أردت تعديل جميع الحقول، غيِّر السمة Blockly.FieldTextInput.prototype.spellcheck_.
إنشاء أداة للتحقّق من صحة إدخال النص
قيمة حقل إدخال النص هي سلسلة، لذا يجب أن تقبل أي أدوات التحقق سلسلة
وتعرض سلسلة أو null أو undefined.
في ما يلي مثال على أداة التحقّق من الصحة التي تزيل جميع أحرف a من السلسلة:
تاريخ التعديل الأخير: 2025-09-11 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","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"]],["تاريخ التعديل الأخير: 2025-09-11 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\u003cp\u003eA text input field stores a string value and allows user text input, with the value always being a valid string.\u003c/p\u003e\n"],["\u003cp\u003eYou can create text input fields using JSON or JavaScript, customizing them with options like spellcheck and validators.\u003c/p\u003e\n"],["\u003cp\u003eText input fields can be serialized and deserialized using JSON or XML, representing the field name and value.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003esetSpellcheck\u003c/code\u003e function allows control over individual field spellchecking, while \u003ccode\u003eBlockly.FieldTextInput.prototype.spellcheck_\u003c/code\u003e affects all fields.\u003c/p\u003e\n"],["\u003cp\u003eValidators for text input fields accept a string and return a modified string, null, or undefined to enforce specific input rules.\u003c/p\u003e\n"]]],["Text input fields store a string as both their value and text, with the value always being a valid string. Creation involves defining the field in JSON or JavaScript, specifying a default text and optional spellcheck. The constructor and JSON allow setting a value, defaulting to an empty string if `null` or `undefined`. Serialization uses JSON and XML, where field names and values are stored. Spellcheck can be toggled, and validators are functions that accept and return strings, `null`, or `undefined`.\n"],null,[]]