Input Processing with Regular Expressions
From FiFormsWiki
FiForms allows you to use regular expressions to process and reformat user input before it is saved to the database, as well as re-format it for display and editing.
Contents |
Input Validation
When input is submitted to FiForms, the server can perform validation on the input data, and reject data that does not match a given regular expression. If formatexp attribute on an iText, iTextArea, iDBSelect, iHidden or iNumber element is set, then it is interpreted as a regular expression. If the input does not match the regular expression, then an error message is displayed, and the data is not saved to the database. The error message can be customized by setting the formaterror attribute.
Examples
<iText
field="SSN"
caption="Social Security Number"
formatexp="^\d\d\d-\d\d-\d\d\d\d$"
formaterror="You must enter a valid SSN in the format ###-##-####" />
Input Processing
When data is submitted from the user, it can be processed by a regular expression search and replace. (See http://us2.php.net/preg_replace ) The attribute inputmatch is a regular expression pattern, which is "searched" for in the user input. The attribute inputformat is the "replace" value.


