Text Field - Question Type
Overview
The Text Field question is the most common question type. Users are provided with a basic text box to type a response to a question or instruction, as follows:
Usage
How to create a Text Field question:
From the toolbox, drag and drop a Text Field question onto a page, section column or tab and set the question’s properties as below.
Property | Description |
---|---|
Question Text | The title of the question |
Text Position | The position in which to display the Question Text on the form. The options are: - Top - Left - (None) |
Mandatory | Checking this box will make the question mandatory. It is unchecked by default. |
Default Value | Sets a default value for the Text Field when it appears in Produce. Default values can contain: - Any text including numbers or dates. - A named date such as ‘tomorrow’. - References to other questions. |
Data Type | Set the data type to one of the following: - Text - Date - Number - Password - Currency - Phone Number |
Character limit | You can type in a character limit which will set the maximum number of characters allowed. |
Width (Pixels) | This will set the maximum number of pixels wide the field will be. |
Text Rows | The number of rows that are displayed to the end user in Produce. By default, only one row is displayed. |
Watermark | A watermark displays a placeholder value of an HTML input textbox until the user has provided some valid text. Watermarks are not the same as default values as they are used purely for informative/example purposes and don't count as a repose to the question. i.e. If no input is made to a text field displaying a watermark, the actual field content is considered to be blank. If those cases where the text field has a default value, then the watermark will not be displayed unless the user deletes the current text. Note: IE does not show the watermark when the textbox has focus, other browsers do. IE8 and 9 do not support this feature natively but it is simulated through JavaScript. |
Help Text | Help text can be added to give additional information about what is being requested in the question. This is a rich-text box. |
Comments | Check this box to allow comments. It is unchecked by default. |
Style | The options are: - Alert (error) - Alert (info) - Alert (success) - Alert (warning) - Jumbotron - Label (default) - Label (error) - Label (info) - Label (primary) - Label (success) - Label (warning) - Well |
Find Dependencies | Clicking this link will open a pop-up window that will show any dependencies that this label has. |
From the Placeholders tab, drag and drop the necessary bookmarks or tags onto the answer.
Text Field Question Reference Defaults
Data collected by the question set can be reused as the default value of other Text Field questions. For example, a client’s surname could be the default for their partner’s surname. This process involves using a question reference as the default value.
In addition to referencing a Text Field question, it’s possible to reference a field retrieved from a data-driven question such as a data field. For example, if a customer’s details are retrieved from a customer database and used as the default values of Text Field questions, you can enable users to accept or change the retrieved data as needed prior to its inclusion in the document.
Default values can only reference questions that appear before the current question in the question set. To set up a reference, populate the question’s default value property with a question reference.
Text Field Validation
To ensure the quality of user input, Infiniti enables you to apply validation rules to Text Field questions. If the end user enters an invalid response to the question, Infiniti will display an error message. For example:
Infiniti provides three validation types as described in the table below:
Validation Type | Description |
---|---|
Compare | Compares a user’s response to a value, calculation or a preceding question. For example, the compare feature could be used to ensure that: - an applicant is over a certain age - a price is between $0.00 and $1,000.00 - a delivery date is no more than 10 days after the purchase date - a parent was born before their children - an order number begins with ‘ORD00’ |
Field Length | Field length validation limits the question response to a minimum and/or a maximum number of characters in length. This can be used to ensure a name is less than 50 characters long, or a code is exactly four characters. |
Regular Expression | Infiniti supports regular expression matches for complex data validation. For example, to ensure an email address is in the correct form complete with @ symbol. |
How to create Text Field validation rules
Select the Text Field question you wish to validate and navigate to the Validation tab.
Select a Validation Type from the drop-down list and enter an Expression for the validation. An expression can be a constant value, question reference, calculation, or regular expression. Some examples are provided below:
Validation | Type (Comparison)/Expression |
---|---|
Greater than 100 | Compare (Greater Than) 100 |
Begins with ABC | Compare (Begins With) ABC |
Happened on or after 01/01/2000 | Compare (Greater Than or Equals) #01/01/2000# |
Delivery date is after invoice Date | Compare (Greater Than) [q1] |
Applicant is at least 18 years | Compare (Less Than or Equals) DateAdd(0,-18,today()) |
Valid email address | Regular Expression \w+([-+.']\w+)@\w+([-.]\w+).\w+([-.]\w+)* |
Note
that dates as expressions must begin and end with ‘#’ or they will be processed as a calculation with the ‘/’ being used as a division symbol. Also note that question references must reference a preceding question.
Enter a meaningful error in the Message property otherwise a default message will be displayed. An error message such as ‘Value must be between 1 and 100’ is much better than ‘Invalid value’.
Note
The Message property can include question references to build messages dynamically, e.g. '[q2] is an invalid date'.
Click Add to store the validation rule.
Comma-separated number or value formatting
To format numeric values the following format string or similar can be applied:
###,###,##0.00
Note
Be sure to have at least one '0' in your formula. Otherwise, your '0' will resolve to '' (empty) in your generated document.
Validating and Formatting Phone Numbers
Selecting the Phone Number data type does not automatically apply validation, as the desired/allowed formats may vary significantly between projects. Selecting this data type only prompts mobile browsers to present the user with a "number input" keyboard instead of a normal "text input" keyboard. Validation of the entered data should be done via the same methods as for the Text data type.
Phone numbers are generally formatted according to a standard, for example:
Landline: (02) 6280 6244
Mobile: 0404 111 333
Simple validation
A simple way to achieve phone number formatting is to validate the question in Produce so that the user is forced to enter 10 digits with no spaces.
Note
If phone numbers in your area start with a 0, a number field will not work as the browser will remove leading 0's (Real numbers don't start with 0)
Set your text field data type to 'Number' and a character limit. On the validations tab, set a minimum length. Finally, once it can be ensured that the number will be entered as a 10 digit string, a format string can be applied so it appears correctly in the document.
Advanced validation
Where a phone number might start with a 0 or require characters such as ( ) + you will need to set your Text Field data type to text. Validating a phone number with these requirements can be difficult and specific to a local area.
You can make use of a regular expression by selecting the validation tab in Design and selecting the type 'Regular Expression'.
Warning: Regular expressions are a powerful yet complex form of validation. It is recommended that any use of regular expressions for validation is tested thoroughly
Validates an Australian Mobile number - 0411 234 567
^\({0,1}((0|\+61)(4)){0,1}\){0,1}(\ |-){0,1}[0-9]{2}(\ |-){0,1}[0-9]{2}(\ |-){0,1}[0-9]{1}(\ |-){0,1}[0-9]{3}$
Validates an Australian Phone Number - including area code - (02) 6280 6244
^\({0,1}((0|\+61)(2|4|3|7|8)){0,1}\){0,1}(\ |-){0,1}[0-9]{2}(\ |-){0,1}[0-9]{2}(\ |-){0,1}[0-9]{1}(\ |-){0,1}[0-9]{3}$
Numbered Lists (Ordered Lists) In Question Text
A typical numbered list can be created as question text using the following HTML tags.
<ol>
<li>Coffee</li>
<li>Milk</li>
</ol>
Decimal place validation
If you need your form project to capture numbers that must have a specific number of decimal places, you can add Regular Expression validation in Design. The following regular expressions will validate to the noted number of decimal places:
1 \d+(.\d{1,1})?
2 \d+(.\d{1,2})?
3 \d+(.\d{1,3})?
4 \d+(.\d{1,4})?
5 \d+(.\d{1,5})?
6 \d+(.\d{1,6})?
Ensure answers start with capital letter
If a response to a text field question must start with a capital letter, the following regular expression validation can be applied:
Note
Make sure that a meaningful error message is applied to avoid confusion (i.e. surname must start with a capital letter).
If answers must start with a capital letter
If a response to a user prompt question must start with a capital letter, the following regular expression validation can be applied:
To make this happen, do the following:
- In the right navigation, select Validation.
- In the Expression section, add the following [A-Z]{1}.*
Note
Make sure that a meaningful error message is applied to avoid confusion (i.e. surname must start with a capital letter).
Named Date
Infiniti allows keywords to be used inside of date text fields to select certain dates. This is useful if the required date is unknown. For instance, Infiniti Produce can interpret a set of commonly named dates if a certain date is unknown.
For example, the "today" keyword may be used to input today's date.
Named Dates can also be used in Design as the default value for date text field questions and validation.
Available Named Dates:
Christmas | Christmas eve | day after tomorrow | day before yesterday |
---|---|---|---|
easter | easter Sunday | easter Sunday | Friday |
good Friday | last week | last year | Monday |
new years | new years day | new years eve | new years eve day |
next Friday | next Monday | next Saturday | next Sunday |
next Thursday | next Tuesday | next year | past year |
today | tomorrow | Tuesday | Wednesday |
x-mas | x-mas eve | xmass | x-mass |
xmass eve | yesterday |
Note
This Feature is built into the Produce user interface and will only work for projects that are loaded in Produce. Fully automated projects that run outside of Produce should avoid this feature.
Setting width for Text Field
A width can be specified for a Text Field's text box and is set in terms of pixels. This feature reduces the usage of space by a particular field.
Example
Infiniti web form which contains three Text Fields: Postcode, Email, and Address with widths set as 75px, 250px and 400px respectively.
Text Field - Aligning currency & numbers to the right
In Design, Text Fields set to either currency or number can be aligned to the right. By default, this setting is OFF. However, to force right alignment, the relevant property must be set.
Steps
1.Go to Design and open the relevant project.
2.Choose the relevant Text Fields.
3.In the Properties tab at the bottom of the screen, check the Right Align checkbox.
Note
This is displayed for currency and numbers only.
Text Field- Password Data Type
In Design, open any project and add a Text Field. For passwords, it can be configured via the Data Type Pulldown:
Complete the remaining part of the Text Field as normal;
In Produce, Setting a Text Field as a Password will have the following effects:
- When typing into the password field, the characters will be hidden.
- When being redisplayed the password field will always show 6 characters if there's more than one character typed in (they're #s behind the scenes). The value of the question will remain unchanged (whatever the user typed in).
- If you type into the field, and then leave it (resetting it to ######), the next time you type a character the field will be cleared (preventing people from pressing backspace and then typing something and ending up with their password being "####ri" or something similar).
- The value of the password field will be encrypted in Answer Files, but if you put in a question reference the reference will be unencrypted (such as if you're passing the password to an Action).
Updated about 2 years ago