We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 41185 ☆ A M B ☆
    • 23 Posts
    I am trying to block free emails eg: google.com, live.com etc using regx. Its not working, please help...

    Here's my FormIt call:

    [[!FormIt?
    &hooks=`spam,email,redirect`
    &vTextRegexp=`No free emails please`
    &emailTpl=`MyEmailChunk`
    &emailTo=`[email protected]`
    &redirectTo=`117`
    &validate=`name:required,
    email:required:regexp=^([\w-\.]+@(?!gmail.com)(?!yahoo.com)(?!live.com)([\w-]+\.)+[\w-]{2,4})?$^,
    subject:required,
    text:required:stripTags`

    ]]

    http://rtfm.modx.com/extras/revo/formit/formit.validators

    regexp vTextRegexp

    Regards,
    Mangesh
      Developing Themes/Templates for MODx Revo. Visit http://mdxthemes.com
      • 3749
      • 24,544 Posts
      I haven't used regex with FormIt, but I would think you'd need delimiters at each end of the regex (in addition to the ^ marks). I could be wrong.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 23491 ☆ A M B ☆
        • 1,056 Posts
        Quote from: trussframework at Apr 23, 2014, 09:10 AM

        email:required:regexp=^([\w-\.]+@(?!gmail.com)(?!yahoo.com)(?!live.com)([\w-]+\.)+[\w-]{2,4})?$^,

        The problem has to do with {2,4} in your regex, and the way FormIt parses &validate.

        The issue? The comma ( , ) is causing an unintended split, resulting in an invalid expression being sent to preg_match.

        (ERROR @ fivalidator.class.php : 682) PHP warning: preg_match() [<a href='function.preg-match'>function.preg-match</a>]: Unknown modifier '{'


        I will file this as a bug on the official FormIt repo.

        UPDATE: See https://github.com/modxcms/FormIt/issues/14 [ed. note: pixelchutes last edited this post 12 years, 4 months ago.]
          Mike Reid - www.pixelchutes.com
          MODx Ambassador / Contributor
          [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
          ________________________________
          Where every pixel matters.