====== Text Inputs ====== The different text input questions are designed for different use cases: * The "Text Input" displays one or more text inputs. * Each text input may or may not have a label (before and/or after the input). * The text inputs may be single- or multi-line inputs. This allows for large input boxes for longer texts. To create a multi-line input, set a height for the text input. * The format that is expected for the text may be specified for each text input. To do so, click the text input in the **List of Questions**. This allows, e.g., to accept only numbers. * For all inputs of a question, or for single inputs, it's possible to specify an //alternative option// ("no answer"). If enabled, a checkbox will be displayed right of the input. * You may specify a constant sum for all inputs of a question, if you're expecting numeric answers. The current sum will then be displayed below the inputs, and the respondent will (optionally) be unable to continue unless the sum matches your expections. This may be useful if, e.g., you want 100% distributed on different categories. * "Free Mentions" are optimized to collect ideas or arguments, i.e., a series of similar contents. * Compared to a multi-line text input, this has the advantage that each line will be stored in a distinct variable. Further, the number of answers will be counted automatically. * By default, the free mentions initially display 2 text inputs. If the respondent enters some text, further inputs will appear. * The "Cloze Text" displays text inputs within running text. Each single text input may be formatted like in the "Text Input". * The [[:en:create:questions:suggest]] displays a text input (or multiple copies of it) and defines a series of possible responses. As soon as the respondent types few characters, matching responses will be offered. If one of the predefined options is selected, it will be encoded automatically. Optionally, you may allow the respondent to type something different, which will be stored as text. * For "Balloon Test", first upload an image in **Images and Media Files**. The question will then display the selected image and text input boxes that you place on the image. ===== Width and Height of Text Inputs ===== You can set the //Width// of text inputs as follows: * No entry means ... * ... for the cloze text, that no input field is displayed. * ... for the open text input, that the full width is used for the input field. * A value from 1 to 15 defines the number of characters that shall fit into the input field. This width varies with the size of the font used. * A value of 16 or more (default: 200) defines the width in pixels to be used for the input field. This width is independent of font size and layout. For the open text input and for [[:en:create:selection-textinput|input fields in selection questions]], you can also set a //Height// for the input fields. * If you do not enter a height, a single-line input field is created. If the text is longer than the input field, the text moves to the left. * If you enter a height, a multi-line input field is __always__ created. If more text is entered than fits the width of the input field, the text wraps into the next line. * If you additionally activate the option //Adjust height automatically//, the input field grows if the height is not sufficient for the text. **Important:** Do __not__ enter a height if you do not expect multi-line input. If you want to adjust the height of single-line input fields, make a corresponding change in the [[:en:create:layout|Questionnaire Layout]]. ===== Restrictions for the Entered Text ===== The open text input (as well as open input fields in other question types, by the way) allows an automatic check of the input format. This is especially recommended if the respondents should enter numbers (e.g. age) or a date. But other applications are also possible, e.g. if the respondents are to enter an amount of money with decimal places or exactly 2 letters. In the **List of Questions** on the left, first select the question and then the input field within the question. For multiple choice questions select the [[:en:create:selection-textinput|Free text inputs within a selection]]. {{:de:create:questions:scr.text.charset1.png?nolink|Auswahl des Eingabefelds in der Navigation}} Alternatively you can click on the button for editing ({{::button.edit3.png?nolink|Button: Edit}}) the item or input field settings within the question. {{:de:create:questions:scr.text.charset3.png?nolink|Detaileinstellungen für ein Eingabefeld aufrufen}} In the detail settings for the input field you will find the //Text input restrictions//. Select here at //Defined characters// which input format should apply to the selection field. **Note:** If you specify a "number" or "decimal number" as //defined characters//, the input in the input field is right-aligned by default and the entry is treated as a number when the data is downloaded. The "numbers", on the other hand, are treated as text consisting of numbers. {{:de:create:questions:scr.text.charset2.png?nolink|Einstellungen für das Format einer offenen Texteingabe}} Depending on the selected format, further restrictions can be set. For numbers a range of values or for letters the number of characters. For more complex formats the setting //Regular expression// is available. If something is entered here, this deactivates any format defined in //Defined characters//. A regular expression that requires e.g. two capital letters (without umlauts) and two digits would look like this: /[A-Z]{2}[0-9]{2}/ For a detailed documentation of regular expressions please refer to [[https://www.regular-expressions.info/|regular-expressions.info]]. ===== JavaScript for Text Inputs ===== SoSci Survey employs JavaScript, for example to limit which characters (digits, letters, etc.) a respondent may use in a text input. Using [[:en:create:javascript|JavaScript]], the behavior of text inputs may be customised further. ==== Allow Formatting Text ==== The JavaScript library [[http://www.sceditor.com/|SCEditor]] (automatically available in SoSci Survey) allows to reconfigure text inputs in a way that respondents can format the text -- like in a word processing software. For example, underline words, add emoticons, etc. First, create a question of type "text input" and a multi-line (!) text input in this question. To create a multi-line text input, set a height (e.g., 120 pixels) for the input. Place the question on the appropriate page, using **Compose Questionnaire**. Then, place an PHP code with the following content on the same page to load the SCEditor: library('SCEditor'); The next step is to create a new text element at "Text Elements and Labels" (using the ID "jsSCEditor", for example, and type "HTML code") and add the following content: Place this text element on the same page, below the question. The JavaScript code will allow formatting in all multi-line text inputs (''