A validation rule can be based on regular expression pattern matching. For example, you can do the following:
The following JavaScript example enforces telephone number format as +nn nnn-nnn-nnnn:
phone=/\+\d{1,3} \d{3}-\d{3}-\d{4}/;
Wrap regular expressions defined in XML in CDATA, as in the following example:
<ValidationRule name="Phone pattern" description="+nn nnn-nnn-nnnn" messageid="4001"> <RegularExpression> <![CDATA[ ((\+|\d)*+(\s*|\x2D))?\d\d\d-\d\d\d-\d\d\d\d]]> </RegularExpression> </ValidationRule>
Validation rules based on regular expressions must comply with the requirements defined in the java.util.regex package.
Copyright © 2013 CA.
All rights reserved.
|
|