Text Field
Last updated
Last updated
Text input fields are the most common elements in a form. Symphony provides two types of elements for text input fields: Text fields are for a single-line input; and Text area is for multi-line input.
Attribute
Type
Required?
Description
name
String
Yes
Identifies the text field.
placeholder
String
Optional
Specifies a short hint that describes the expected value of the input field.
required
Boolean
Optional
If true
, it specifies that the input field must be filled out before submitting the form.
masked
Boolean
Optional
If true
, it creates a masked text field with hide/show options when its value is "true". For more information, refer to Masked Text Field.
maxlength
Integer
Optional
The maxlength
attribute allows you to specify a maximum number of characters that the user can input.
minlength
Integer
Optional
The minlength
attribute allows you to specify a minimum number of characters that the user can input.
pattern
String
Optional
Regex String to match for input validation. For more information, refer to Regular Expressions - Regex.
pattern-error-message
String
Optional but if pattern
is defined, the pattern-error-message
attribute is mandatory.
Error message returned to user if pattern
parameter matches user input
title
It accepts a simple text and \n
for line breaks
Optional
The description that will be displayed when clicking the tooltip icon located on top of the Text Field Element. Max length: 256 characters. Available from Symphony v20.8 and above.
label
String
Not required but it is recommended if title
is defined
Definition of the label that will be displayed on top of the Text Field Element. Available from Symphony v20.8 and above.
auto-submit
Boolean
Optional.
Default false.
When enabled, typing <enter
> key in the field will submit the form.
With Symphony v20.6, bot developers can use Regex to validate text fields
and text areas
using the pattern
and pattern-error-message
attributes.
For more information and examples, refer to Regular Expressions - Regex.
The text field has a max number of 128 characters. For larger texts, use Text Area.
The text field cannot have children tags but it can have a default text (initial value) between the <text-field></text-field>
tags. See Examples below for more details.
Text fields are grouped at a max of 4 per row, depending on the screen size. For more information, refer to Alignment of input texts.
You can add a default text in your text field by including it between the <text-field></text-field>
tags. Note that unlike the placeholder
text, the default text will be sent with the form if not edited by the user.
Input Validation - Pattern: the max length for all attributes is set to 256.
The following examples show text fields being used as follows:
The first text-field (init) shows how to display a default text ("With initial value"). Note that the default text would have been sent to the payload if it had not been deleted before submitting the form.
The second text-field (placeholder) shows how a placeholder text ("Only Placeholder") is displayed in the UI. Please note the placeholder text is not sent in the payload if no text has been entered in the field by the enduser.
The third text-field (noreq) shows how a user can interact with a non-required field. Even if the field is empty (only a placeholder text is present but does not count as a value), it does not prevent the enduser from submitting the form.
The fourth text-field (req) shows the behaviour of the unique required field of the form, which cannot be submitted in case it is not filled; an error is displayed under the field in case the user submits the form with this empty field.
The fifth text-field (regex) shows the behaviour of the field when a regex pattern is entered. You can note that the pattern-error-message is displayed under the field if the input does not follow the pattern required by the bot developer.
The sixth text-field (min) shows how to force users to enter an input with a minimum number of characters, and how an error message is displayed under the field if the input does not respect the minlength required.
The seventh text-field (label) shows how a label text ("My Label") is displayed.
The eighth text-field (tooltip) shows how a title text ("My Tooltip/n With a second line") is inserted in the UI under the (i) icon, and how the text entered in the title parameter is displayed when the enduser clicks on the icon.
Please note that several text-fields are aligned next to another. Note also that this behaviour is reactive to the screen size, the number of text-fields on the same line decreasing until one per row, as the screen gets smaller (see in the example below).
Initial release
2.55.9
Since first version
Since first version
Regex
20.6
Since first version
Since first version
Label
20.7
Since first version
Since first version
Tooltip (title)
20.7
Since first version
Since first version
auto-submit
23.11
23.12
Not supported yet.