Using the Data Designer
Custom Validation
The Plain Text and Calculation field dialogs feature a validation section (illustrated below).
You can use the validation feature to ensure the following about the user's input.
- floating point number (Floating point includes scientific notation, so is appropriate for scientific numbers. Decimals usually suffice for business numbers.)
NoteYour system administrator may customize the choices.
- The field value has one of the following relationships with another field, a number, or an expression - the default expressions are
- between two values (either another field or a number that you specify)
- maximum length (usually for text responses)
NoteYour system administrator may customize the choices.
If the user's response fails to meet the criteria, you can compose an error message that appears when the data does not satisfy the criterion. Your system administrator determines if a user can save the invalid data.
When the Custom Validation button is clicked, the Custom Validation dialog appears.
- The Data Type field is the value's basic type, for example, text number or URL.
- The Condition field displays the validation logic.
- The Examples drop-down list shows validation expressions that the data design creator can apply to the field.
- Any Error Message displays in Data Entry mode when the user inserts an invalid value.
When the Select Field button is clicked, the Select a Field or Group dialog appears.
This dialog displays fields that can be inserted into the Condition field. Some field types, like the RichArea field, are not listed. See Also: Referencing Other Calculated Fields
Example of Creating Custom Validation
As an example of custom validation, assume that a field collects telephone numbers, and you want to make sure the user enters 10 digits. To accomplish this, follow these steps.
- Click the Plain Text Field dialog and complete the screen.
- In the validation section, click Custom Validation. The Custom validation screen appears.
- In the Data Type field, select Whole Number from the drop down list. This ensures that the user can only enter digits.
- Click Maximum text length... . This option lets you specify the length of the user's response.
- string-length(.) <= {X} appears in the Condition field.
- Since you want the user's input to equal 10, remove the less than sign (<) from the calculation. Now it looks like this: string-length(.) = {X}.
- Replace the X with 10. Now, it looks like this: string-length(.) = {10}.
- Move the cursor to the Error Message field and compose a relevant error message. For example: must be 10 digits.
- Your screen should look like this.
- Press OK and return to the Plain Text field dialog.
- Press OK to save that dialog and test the validation on the phone number field. To do this, switch to Data Entry mode and enter more or fewer than 10 digits, as well as non-digit characters to verify that validation works as expected.