HELP!

How do I validate user input?

User input captured via Dialog Objects can be validated using any of the following techniques:

The allowblank Object System Property

The allowblank Object System Property can be set to indicate if a question on a Dialog can be left blank. At runtime, by default, a red asterisk * character appears next to questions whose allowblank value is set to false.

Please note that if a question is left blank until it is used in a Knowledge Object (e.g. Decision Tree) then the user would be prompted for it using the tied Dialog.

If the value of a Blank Question is checked in a script without checking its isempty system property first then an error message is generated and the application is terminated.

Checking the Min & Max values for Numeric Questions

The minimum and maximum valid values for a Numeric and Date Questions capture can be set using the MinValue & MaxValue Object System Properties. If a value outside this range is entered by the user then a warning is displayed and no progress to the next stage (Leaving a Dialog or going to the next Chat question) is prevented.

The values of all Object System properties can modified by the developer directly via Edit Advanced Settings. System property values can also be set dynamically at runtime via a Script.

Using Decision Flow Trees to loop back to a Dialog when the captured values are invalid

image descr

Linking a Script to the oncanexit property of a Dialog

This script can be used to check current values (or a combination of current values) to indicate invalid input and prevent the user from leaving the dialog until validity is established.

image descr

The Script (JavaScript or XpertScript) tied to oncanexit should include a "return" statement to determine the dialog exit status:

return i;

where:

  • i=0 : Do not exit the dialog
  • i=1 : Exit the dialog
  • i=2 : Normal dialog exit

Example (JavaScript)

if ((#age.val()<18) && (#product_category.val()=="A")) {
  aObject = dictionary.findObject("my_dialog");
  aObject.val("warning_label","caption","Warning: This product cannot be sold to persons under 18");
  return 0;
} else {
  return 1;
}

On This Page