Back

Editing, Updating and Creating Records
validation
Javascript or input mask for data and error message on error We provide 3 types of validation. 1. Input mask. For example, #### means enter exactly 4 digits. 2. Special validation functions. For example, =EMAIL means that this field should be checked for the standard internet email format. 3. Regular expression. Regular expression is activated if first character is =. 4. Javascript expression. Javascript is activated if the first character is %. This is since phpLens 3. When we use input mask validation, we can enter in the input mask the following:
X | 0-9 and A-Z, must exist
x | 0-9 and A-Z. This character is optional.
# | 0-9 or . and +/- must exist.
9 | 0-9 or . and +/-. This character is optional
+ | Positive numbers only
& | Any character, must exist
? | Any character, optional
\ | escape character
> | Uppercase
< | Lowercase
Examples
Telephone numbers with no area code. 7 digits must be filled, but some newer phone numbers have 8 digits, so make 1 character optional. | `9###-####`
Car part number with the format: 3 digit number, a hyphen followed by a 3 or 4 letter code | `###-XXXx`
Validation Functions The first character must be the equals (=) character. The code is not case-sensitive.
Description | Code
To validate email of the form: user@domain.com | `=EMAIL`
Credit cards (not yet) | `=CREDITCARD`
To validate email a regular expression is used. This regular expression is defined as a constant called `PHPLENS_EMAIL_REGEX`. You can override it by defining this constant before phplens.inc.php is included in your main php file. The regular expression used is the ugly but powerful: `^(\S+@).+((\.com)|(\.edu)|(\.gov)|(\.int)|(\.mil)|(\.net)|(\.org)|(\.info)|(\.biz)|(\.name)|(\.pro)|(\.museum)|(\.coop)|(\.aero)|(\.[a-z]{2,2}))$` Regular Expressions The first character must be the equals (=) character. All subsequent characters are treated as standard Javascript regular expression characters. /expr/ delimiters are not required.
Value must be either CAR or BOOK, case-insensitive. The $ at the end indicates that no further characters will be accepted. | `([Cc][Aa][Rr])|([Bb][Oo][Oo][Kk])$`
Value must begin with 'A' or 'a' followed by any other characters | `[aA].*`
Remember that the regular expressions are case-sensitive. You do not need to enter the ^ and $ in ^expr$ at the beginning and end of the regular expression as it is done automatically for you by phpLens. The second optional parameter is the error message on error. Javascript Expression The first character must be % to activate this. Any hash (#) character in the expression is substituted with the field value. To check if a value entered is between 10 to 20, use: $lens->validation='Col^%10 <= # && # &;lt;= 20'; Encoding Because ^ is used by regular expressions and phpLens as a seperator, we also allow a raw url encoded format. If the first and last characters of a validation setting are both '/', then the contents are raw url encoded as in the example below: # =^[0-9][0-9]\.[0-9]$ $lens->validation='Col^/%3D%5E%5B0-9%5D%5B0-9%5D%5C.%5B0-9%5D%24/'; Syntax `$lens = "ColumnName^Validation Mask^Invalid Error Message"; $lens->validation = "PHONE^#######9^Phone number must be 7 or 8 digits"; To treat a column as an email column: $lens->validation = 'mailaddress^=EMAIL'; # value must be greater than 0 $lens->validation='Col^%0 < #';` Basic:No Advanced/Enterprise:Yes DynamicEdit:Yes [Version 1.0]