PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

RegEx Validation on Submit

  1. I did some searching but didn't find anything. I apologize if this is a repeat request.

    What are the chances of having RegEx (or even simple string) validation per field added to GF? We're looking to confirm that e-mail addresses are from a specific domain and, while I'm sure I could do this with a plugin or jQuery, I'd love to see something built into GF that we could use site-wide.

    Thanks!

    Posted 9 years ago on Tuesday August 3, 2010 | Permalink
  2. http://forum.gravityhelp.com/topic/australian-phone-format#post-8113

    ... We plan on adding REGEX capabilities in the future so you could write your own validation using REGEX to customize any of the fields. This will be done via a hook. No timetable, it's just on our feature list for a future release

    Posted 9 years ago on Tuesday August 3, 2010 | Permalink
  3. Very cool.

    Any possibility of adding this feature into the main form editing views under the advanced tab rather than having to use a hook / PHP?

    Posted 9 years ago on Tuesday August 3, 2010 | Permalink
  4. I'm not sure at this point. The reason why we may add it only as a hook is 90% of our users don't know what REGEX is so we need to balance out adding additional features to the UI itself when most developers are comfortable doing things with code. If you don't know what you are doing with REGEX it can cause problems, so chances are if you are good at REGEX you should have no problem adding a hook. That is our thinking.

    Posted 9 years ago on Tuesday August 3, 2010 | Permalink
  5. Sure, though you could do something similar to the Conditional options and have a checkbox to turn on validation rules while usually hiding the interface. I might even have a "Use regular expressions (click here for more information)" checkbox under the rules input box so that if unchecked you simply use strpos() or something similar to find a string occurrence.

    Implementation using hooks adds a ton of complexity to the customization process, especially when you have users creating new forms on an almost daily basis and don't want to have to apply the same validation rules to each form. In terms of implementation, it would almost be easier to just use jQuery instead.

    Slightly off-topic, though related - do you accept code submissions?

    Posted 9 years ago on Tuesday August 3, 2010 | Permalink
  6. Whenever I hear talk of regular expressions, I think of this quote:

    Some people, when confronted with a problem, think
    “I know, I'll use regular expressions.” Now they have two problems.

    Not that it applies in any meaningful way here.

    Posted 9 years ago on Tuesday August 3, 2010 | Permalink
  7. @laverne_web You make good points about the REGEX. We will look into it when we include that in a development cycle and may go ahead and implement it the way you suggested. That was how we originally were going to implement it before thinking about going the hook route.

    We are open to people submitting changes to us and we will consider integrating them into a future release as long as we think it is something that will benefit our use baser as a whole.

    Posted 9 years ago on Wednesday August 4, 2010 | Permalink