Creating or configuring forms > Configuring the <components> element > Configuring a text box

6.1.16 Configuring a text box

A text box allows users to input any string data into a field. Restrictions can be placed on the text box to define what the valid inputs are.

To add/delete/modify a text box

  1. Open the appropriate XML file located in the Viewpoint home directory. Locate the <components> element.
  2. Create the <component> with a unique id.
  3. Insert the <text-value> element.
  4. (Optional) Set restrictions on the text using the <regex> child element. The expression is used to validate the input as defined by regular expression pattern matching. If it is not set, all inputs are considered valid. Regular expressions must use the JavaScript regular expression syntax.
  5. (Optional) Set a default using the <default> element.
  6. (Optional) Set the <error-msg> element to clarify the purpose of an error in a message should the regex validation fail.
  7. <component id="zip" required="true">
      <description>Zip Code</description>
      <text-value>
        <default>84043</default>
        <regex>^\d{5}$</regex>
        <error-msg>Zip code must be exactly 5 digits</error-msg>
      </text-value>
    </component>

    The text must match /^d{5}$/ (5-digit zip code) with a default value of 84043.

  8. (Optional) Set the text box to mask the text to protect passwords. To do so, set the <text-value> type to "password".

Related topics