• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

Regular Expression validation

  • Views Views: 15,690
  • Last updated Last updated:

Navigation

      Access element (+)
      Birthday element
      Button element
      Calculation element
      Captcha element
      Checkbox element
      Colour Picker element
      Count element (+)
      Database join element
      Date element
      Digg element
      Display text element
      Dropdown element
      Facebook Like element
      Field element
      File Upload element
      Folder element
      Google Map element
      Image element
         Image databese join
      Internal id element
      IP element
      J!Date element
      Kaltura element
      Link element
      Notes element
      OpenStreetMap element
      Picklist element
      Radio Button element
      Rating element
      Sequence element
      Slider element
      Tags element
      Textarea element
      Thumbs element
      Time element
      Timer element
      Timestamp element
      Total element
      User element
      User group element
      Video element
      View level element
      YesNo element
      Youtube element
      Akismet validation
      Is Email validation
      Is Not validation
      Is Numeric validation
      Not empty validation
      PHP validation
      Rsa id
  • 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​

    US Phone number​
    Code:

    /^[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​

    Code:

    /\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​
    Code:

    /(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​
    Code:
    /^\w*$/
Back
Top