Execute script client side after form validation

Hello, I would like to execute a client-side JavaScript function (which runs once someone clicks the submit button). I’ve used an event listener on the submit button, but the issue is that it runs even if the form encounters an error. I want my JS function to execute only if the form is submitted without any errors.

It should run just before this hook: gform_pre_submission_filter - Gravity Forms Documentation

There isn’t a JavaScript hook or event that occurs after validation and before gform_pre_submisison_filter. Validation occurs server-side during form submission, so there’s no way to inject or trigger JavaScript in the middle of that process. At this time, there is only one JavaScript hook that runs after validation, it is for Ajax enabled forms, and is triggered when the confirmation message is displayed:

You can suggest, directly to the product management team, that the form submission process should be refactored to support client-side processing and more JavaScript hooks and/or events, on the Gravity Forms product roadmap page.

The issue is that my form cannot use AJAX since I am using Stripe with additional payment methods enabled. My problem is that when a form is submitted, there is often a 5-second wait because an API call is made, along with some other functions executed via the gform_pre_submission hook. While all these functions are being processed, I would like to display a loading icon on the page. However, to do this, I need to be able to execute a script at that moment. My event listener on the submit button is not sufficient because the loading overlay is displayed even if the form encounters an error during submission.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.