How to validate input values by writing Regular Expression rules
Risk Cloud uses the standard JavaScript RegExp constructor for validating Field input values entered by end-users. Certain Field types (Number, Text, Text Area, etc.) allow the entry for a RegExp validation string which will check against the input value.
Regular Expression Examples
For example, to create a validation that would require the user to enter the letter A, B, or C followed by 4 numbers you would enter the pattern validation string of
^[A-C][0-9]{4}$
Common RegEx Examples
-
5 Digit Zip code:
[0-9]{5}
-
Hyphen Separated US Phone Number:
[2-9]\d{2}-\d{3}-\d{4}
-
Email Address:
.+@.+\..+
-
Set a specific number of character for a code/ID field. For example this RegEx will require users to input exactly 9 numbers:
^[0-9]{1,9}$
-
Date in mm/dd/yyyy or mm-dd-yyyy format:
((0[1-9])|(1[0-2]))[\/-]((0[1-9])|(1[0-9])|(2[0-9])|(3[0-1]))[\/-](\d{4})
To learn more about creating regular expressions, you can visit the links below:
http://www.w3schools.com/jsref/jsref_obj_regexp.asp
Comments
0 comments
Please sign in to leave a comment.