You can dynamically populate
a validation pattern message with a value from a data source. This
allows you to ensure users enter the correct value in the field.
For example, you can display a custom error message when users
enter the wrong pattern in a field.
The schema you connect to could have the following defined for
a validation pattern:
<form>
<validationPattern dp_patternMessage="message1"/>
</form>
The data file you point to could have the following defined for
a validation pattern:
<form>
<validationPattern dp_patternMessage="DP Pattern Message - The order number pattern is: A9A9A9"/>
</form>
When you merge the data file with the form design, and you type
a number in the Order Number field that does not match the pattern
expected, an error dialog box appears.
Another example could be to provide custom error messages for
patterns in another language. The data file you point to could have
the following defined for pattern validation:
<form>
<validationPattern dp_patternMessage="Le numéro de commande doit suivre le modèle suivant : A9A9A9"/>
</form>
When you merge the data file with the form design, and you type
a number in the Order Number field that does not match the pattern
expected, an error dialog box in French appears.
Note:
To use non-ASCII text (such as accents) in your
data file, ensure the file is suitably encoded and the encoding
is correctly identified in the XML processing instruction. For example:
<?xml version="1.0" encoding="UTF-8"?>
Before you perform this task, you must ensure the following settings
are in effect:
-
In the Object Library palette, click the Standard category
and drag an object onto the form design.
For example, insert
a Text Field object.
-
(Optional) In the Object palette, click the Field tab and
type a caption for the object in the Caption box.
For example,
type
Order Number
.
-
Click the Value tab and click Validation Patterns.
-
In the Select Type list, select a validation pattern.
For
example, select Postal Code (Canada) to display the pattern
A9A 9A9
in the
Pattern box.
-
Click the Validation Pattern Message active label.
-
Select the data connection.
Note:
If you
are not already connected to a data source, Default Data Binding
is the only selection in the Data Connection list.
-
Click the triangle beside the Binding box and select a binding.
For
example, select validation > @dp_patternMessage.
The
following string appears in the Binding box:
$record.validation.dp_patternMessage
You could type this string into the Items box instead
of selecting it.
-
Click OK.
-
View the error message by using the Preview PDF tab.
For
example, in the Preview PDF tab, enter an order number that does
not match the pattern.