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.

Open a new Gravity Form upon form validation error

  1. I am looking for the best/easiest way to run a new gravity form when the current form fails validation. Example: user enters a zip code that is not valid upon submission. When the form fails validation a second form opens which is used to gather user contact info so they can be notified when their zip code is available.

    Does anyone have an answer already to this that I was unable to find in the search or have any ideas as to a solution?

    Thanks in advance.

    Posted 7 years ago on Wednesday February 20, 2013 | Permalink
  2. Hi mr_jonboy,

    If you use the gform_pre_render hook, you can check the $form object that is passed for the zipcode field and see if that is the field that failed validation. If so, you can output your custom JS to load the modal with the separate form. Here is some sample code:

    Posted 7 years ago on Wednesday February 20, 2013 | Permalink
  3. Thank you very much. I will give it a go and let you know.

    Posted 7 years ago on Thursday February 21, 2013 | Permalink
  4. I tried to take what was stated above and merge it with a zip code validation array in another post that I found. However this is not creating the desired result. Would someone willing to provide some assistance on this code. Obviously this is pretty new to me. :-)

    Thank you.

    Posted 7 years ago on Monday February 25, 2013 | Permalink
  5. Looking at your code I have a few questions:

    1. Why is the zipcodes array empty on this line?

    2. Your code to open the modal window would be executed for every field in the form, due to where you placed it in the loop. If you look at David's code, the modal dialog will only be added if $zip_failed_validation were true for any field in the loop, otherwise the form is just returned.

    Posted 7 years ago on Tuesday February 26, 2013 | Permalink
  6. Thank you for the reply.

    1. Took zip codes out for the post to save space.
    2. I tried many things but I guess its beyond me on how to properly merge a zipcode array with conditional javascript. Just not sure what I am missing.

    Posted 7 years ago on Tuesday February 26, 2013 | Permalink
  7. 1. OK, got it

    2. If pulling this off is beyond you at this point, it might be helpful to hire someone using our job board or another WordPress job board like

    Posted 7 years ago on Saturday March 2, 2013 | Permalink