Validate Field for Acceptable Characters Only

Mindwatering Incorporated

Author: Tripp W Black

Created: 12/29/2005 at 08:06 AM

 

Category:
Notes Developer Tips
Formulas

Issue:
Need to determine if user entered invalid / illegal characters/numbers into a text field.

Solution:
The following example filters what a user enters by removing the "good" characters. When the result is not an empty string "", then the user entered "bad" character(s). You then can use the result in an if/then for passing/failing validation.

Input Translation:
@Trim(@ThisValue)

Input Validation:
msg1:="The NNNN field is required";
msg2:="Enter only a number with decimal point in the NNNN field.";
tmprmvlst:=@Explode("0;1;2;3;4;5;6;7;8;9;0;."; ";");
tmpremainlst:=@Trim(@ReplaceSubstring(@ThisValue; tmprmvlst; ""));

@If(@ThisValue=""; @Failure(msg1);
tmpremainlst!=""; @Failure(msg2);
@Success)


previous page