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.

Validate field with Regular Expression

  1. Muhammad Mustafa
    Member

    I want to validate 2 fields within my form with Regular Expression
    I searched the forum and found some posts that are not clear enough about how to do it, so please give me a "clear" steps on how to validate a specific text input field with my Regular Expression using hooks/filters or whatever it takes, clearly, which part of the code put where?!
    Thanks,

    Posted 12 years ago on Wednesday May 11, 2011 | Permalink
  2. To do custom validation on a field you use the gform_validation hook.

    You can find documentation for the gform_validation hook here:

    http://www.gravityhelp.com/documentation/page/Gform_validation

    A tutorial on how to use the gform_validation hook to write custom validation can be found here:

    http://www.gravityhelp.com/documentation/page/Using_the_Gravity_Forms_%22gform_valiation%22_Hook

    Posted 12 years ago on Wednesday May 11, 2011 | Permalink
  3. Muhammad Mustafa
    Member

    Thanks Carl, it worked for me :)
    Now, another tiny question...
    I am using conditional logic for some fields within my forms its easy and works great, only one case I can't achieve with gravity where:
    - Field A is a radio button with 2 choices
    - Field B is a drop down menu with 4 values
    - Field C is a text input shows ONLY IF (Field A = Choice1) AND (Field B = value1 OR value2 OR value3)
    - Field D is a text input shows ONLY IF (Field A = Choice1) AND (Field B = value4)
    I can get the Field D to work probably but not Field C hence the lake of 'OR' ability in the conditional logic with gravity, am I missing anything here? is there anyway to do it?

    Posted 12 years ago on Thursday May 12, 2011 | Permalink
  4. Conditional Logic doesn't currently support OR type functionality. It only supports basic conditionals.

    Posted 12 years ago on Thursday May 12, 2011 | Permalink
  5. Muhammad Mustafa
    Member

    Bad news :(
    Thanks anyway Carl, I'll work in a workaround, just put it in your To-Do Features list, gonna be awesome to see such a function in Gravity... Kindly mark this thread as answered and close it, no more question here for now :)

    Posted 12 years ago on Friday May 13, 2011 | Permalink

This topic has been resolved and has been closed to new replies.