रिसर्च सर्वे: Blockly के साथ अपने अनुभव के बारे में हमें बताएं
सर्वे शुरू करें
टेक्स्ट इनपुट फ़ील्ड
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
टेक्स्ट इनपुट फ़ील्ड, स्ट्रिंग को अपनी वैल्यू के तौर पर और स्ट्रिंग को अपने टेक्स्ट के तौर पर सेव करता है. इसकी वैल्यू हमेशा मान्य स्ट्रिंग होती है, जबकि इसका टेक्स्ट, एडिटर में डाली गई कोई भी स्ट्रिंग हो सकती है.
टेक्स्ट इनपुट फ़ील्ड

एडिटर के साथ खुला टेक्स्ट इनपुट फ़ील्ड

छोटा किया गया ब्लॉक, जिसमें टेक्स्ट इनपुट फ़ील्ड है

शॉर्ट वीडियो
JSON
{
"type": "example_textinput",
"message0": "text input: %1",
"args0": [
{
"type": "field_input",
"name": "FIELDNAME",
"text": "default text",
"spellcheck": false
}
]
}
JavaScript
Blockly.Blocks['example_textinput'] = {
init: function() {
this.appendDummyInput()
.appendField("text input:")
.appendField(new Blockly.FieldTextInput('default text'),
'FIELDNAME');
}
};
टेक्स्ट इनपुट कन्स्ट्रक्टर में वैल्यू और पुष्टि करने वाला फ़ंक्शन डाला जा सकता है. हालांकि, ऐसा करना ज़रूरी नहीं है. वैल्यू को स्ट्रिंग में बदला जाना चाहिए. अगर यह null
या undefined
है, तो खाली स्ट्रिंग का इस्तेमाल किया जाएगा.
JSON की परिभाषा की मदद से, स्पेलचेक का विकल्प भी सेट किया जा सकता है.
सीरीज़ के फ़ॉर्मैट में वीडियो रिलीज़ करना और एक्सएमएल
JSON
टेक्स्ट इनपुट फ़ील्ड के लिए JSON इस तरह दिखता है:
{
"fields": {
"FIELDNAME": "text"
}
}
यहां FIELDNAME
, टेक्स्ट इनपुट फ़ील्ड का रेफ़रंस देने वाली स्ट्रिंग है और वैल्यू, फ़ील्ड पर लागू की जाने वाली वैल्यू है. वैल्यू, कॉन्स्ट्रक्टर वैल्यू के जैसे ही नियमों का पालन करती है.
XML
टेक्स्ट इनपुट फ़ील्ड का एक्सएमएल ऐसा दिखता है:
<field name="FIELDNAME">text</field>
फ़ील्ड के name
एट्रिब्यूट में, टेक्स्ट इनपुट फ़ील्ड का रेफ़रंस देने वाली स्ट्रिंग होती है. साथ ही, अंदरूनी टेक्स्ट, फ़ील्ड पर लागू की जाने वाली वैल्यू होती है. इनर टेक्स्ट वैल्यू, कॉन्स्ट्रक्टर वैल्यू के जैसे ही नियमों का पालन करती है.
कस्टमाइज़ेशन
स्पेलचेक
setSpellcheck फ़ंक्शन का इस्तेमाल करके यह सेट किया जा सकता है कि फ़ील्ड में मौजूद इनपुट टेक्स्ट की वर्तनी की जांच की जाए या नहीं.
वर्तनी जांच की सुविधा वाले और बिना वर्तनी जांच वाले टेक्स्ट इनपुट फ़ील्ड

वर्तनी जांचने की सुविधा डिफ़ॉल्ट रूप से चालू होती है.
यह अलग-अलग फ़ील्ड पर लागू होता है. अगर आपको सभी फ़ील्ड में बदलाव करना है, तो Blockly.FieldTextInput.prototype.spellcheck_
प्रॉपर्टी बदलें.
टेक्स्ट इनपुट की पुष्टि करने वाला फ़ंक्शन बनाना
टेक्स्ट इनपुट फ़ील्ड की वैल्यू एक स्ट्रिंग होती है. इसलिए, पुष्टि करने वाली सभी प्रोसेस को स्ट्रिंग स्वीकार करनी चाहिए और स्ट्रिंग, null
या undefined
दिखानी चाहिए.
यहां ऐसे पुष्टि करने वाले फ़ंक्शन का उदाहरण दिया गया है जो स्ट्रिंग से सभी 'a' वर्ण हटा देता है:
function(newValue) {
return newValue.replace(/a/g, '');
}

जब तक कुछ अलग से न बताया जाए, तब तक इस पेज की सामग्री को Creative Commons Attribution 4.0 License के तहत और कोड के नमूनों को Apache 2.0 License के तहत लाइसेंस मिला है. ज़्यादा जानकारी के लिए, Google Developers साइट नीतियां देखें. Oracle और/या इससे जुड़ी हुई कंपनियों का, Java एक रजिस्टर किया हुआ ट्रेडमार्क है.
आखिरी बार 2025-07-25 (UTC) को अपडेट किया गया.
[null,null,["आखिरी बार 2025-07-25 (UTC) को अपडेट किया गया."],[[["\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,["# Text input fields\n\nA text input field stores a string as its value and a string as its text. Its\nvalue is always a valid string, while its text could be any string entered into\nits editor.\n\n#### Text input field\n\n#### Text input field with editor open\n\n#### Text input field on collapsed block\n\nCreation\n--------\n\n### JSON\n\n {\n \"type\": \"example_textinput\",\n \"message0\": \"text input: %1\",\n \"args0\": [\n {\n \"type\": \"field_input\",\n \"name\": \"FIELDNAME\",\n \"text\": \"default text\",\n \"spellcheck\": false\n }\n ]\n }\n\n### JavaScript\n\n Blockly.Blocks['example_textinput'] = {\n init: function() {\n this.appendDummyInput()\n .appendField(\"text input:\")\n .appendField(new Blockly.FieldTextInput('default text'),\n 'FIELDNAME');\n }\n };\n\nThe text input constructor takes in an optional value and an optional\n[validator](#creating_a_text_input_validator). The value should cast to a\nstring. If it is `null` or `undefined`, an empty string will be used.\n\nThe JSON definition also allows you to set the [spellcheck](#spellcheck) option.\n\nSerialization and XML\n---------------------\n\n### JSON\n\nThe JSON for a text input field looks like so: \n\n {\n \"fields\": {\n \"FIELDNAME\": \"text\"\n }\n }\n\nWhere `FIELDNAME` is a string referencing a text input field, and\nthe value is the value to apply to the field. The value\nfollows the same rules as the constructor value.\n\n### XML\n\nThe XML for a text input field looks like so: \n\n \u003cfield name=\"FIELDNAME\"\u003etext\u003c/field\u003e\n\nWhere the field's `name` attribute contains a string referencing a text input\nfield, and the inner text is the value to apply to the field. The inner\ntext value follows the same rules as the constructor value.\n\nCustomization\n-------------\n\n### Spellcheck\n\nThe\n[setSpellcheck](/blockly/reference/js/Blockly.FieldTextInput#setSpellcheck)\nfunction can be used to set whether the field spellchecks its input text or not.\n\n### Text input fields with and without spellcheck\n\nSpellchecking is on by default.\n\nThis applies to individual fields. If you want to modify all fields change the\n`Blockly.FieldTextInput.prototype.spellcheck_` property.\n\nCreating a text input validator\n-------------------------------\n\n| **Note:** For information on validators in general see [Validators](/blockly/guides/create-custom-blocks/fields/validators).\n\nA text input field's value is a string, so any validators must accept a string\nand return a string, `null`, or `undefined`.\n\nHere is an example of a validator that removes all 'a' characters from the\nstring: \n\n function(newValue) {\n return newValue.replace(/a/g, '');\n }"]]