1. The 3.8 code for Fabrik is now available on github, in the 'master' branch. If you are familiar with updating Fabrik from github, we would appreciate it if you could test this code on J! 3.8 for us. Once we have some feedback, we'll build a 3.8 release.

Regular Expression validation

Jan 7, 2016
Regular Expression validation
  • A customizable validation rule. Runs a Regular Expression to test for validation success or failure

    validation-regex.png
    • Error message - The message to display next to the element if the validation fails. This text should explain why the validation failed and what steps the user should take to remedy the error.
    • Condition - A PHP expression which if returns false, means that the validation is not run. See here for more information.
    • Regular expression- A regular expression (must start and end with /)
      • Uses PHP's preg_match function to determine if there is a match in the data. If there is then validation succeeds otherwise it fails
    • Match or Replace
      • If set to match then the validation behaves as normal and on validation failure returns you to the form showing the error message.
      • If set to 'replace' then the submitted value is replaced with the data contained in the field 'Replace string'
    • Replace string - the data to replace the submitted data with if the validation fails and 'Match or Replace' is set to 'Replace'
    • Tip text - The hover text used to describe the validation.
    • Icon - the icon to use for the validation. Appears next to the field label.
    Note that people looking for input masks should use the regular express (or php validation rule)



    Helpful links:

    http://ch.php.net/manual/en/reference.pcre.pattern.syntax.php

    http://www.regular-expressions.info/quickstart.html

    Library of user submitted regular expressions


    Example Regular Expressions (top)


    US Phone number (top)
    Code (Text):

    /^[0-9]{3}-[0-9]{3}-[0-9]{4}|[0-9]{10}|[(][0-9]{3}[)][0-9]{3}-[0-9]{4}$/
     
    Will match the following formats
    • 1231234567
    • 123-123-4567
    • (123)123-4567
    Phone number example:

    US Social Security number (top)

    Code (Text):

    /\b(?!000)(?!666)(?:[0-6]\d{2}|7(?:[0-356]\d|7[012]))[- ](?!00)\d{2}[- ](?!0000)\d{4}\b/
     
    Will match the valid formats as described here http://en.wikipedia.org/wiki/Social_Security_number#Valid_SSNs


    UK Post code (top)
    Code (Text):

    /(GIR 0AA)|((([A-Z-[QVX]][0-9][0-9]?)|(([A-Z-[QVX]][A-Z-[IJZ]][0-9][0-9]?)|(([A-Z-[QVX]][0-9][A-HJKSTUW])|([A-Z-[QVX]][A-Z-[IJZ]][0-9][ABEHMNPRVWXY])))) [0-9][A-Z-[CIKMOV]]{2}) /
     
    Alphanumeric without spaces(top)
    Code (Text):
    /^\w*$/
  • Loading...