Skip Navigation

[Resolved] Is there a way to detect when a cred form is submitting?

This support ticket is created 4 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Tagged: 

This topic contains 5 replies, has 3 voices.

Last updated by Christian Cox 4 years, 6 months ago.

Assisted by: Christian Cox.

Author
Posts
#1859225

I have a cred form that creates business listings for a directory site. There are a lot of fields, including several image fields, and sometimes the delay between clicking submit and the form submission being complete can be quite long. I'm wondering if there is a class applied to the form, or body while the form is submitting, or a javascript event I can hook into, so I can add an overlay to the page and a message that the listing is being created.

#1859283

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Greg,

Thank you for getting in touch.

Actually yes you can hook into the form submit using javascript.

To do it you can follow the documentation for this below.
hidden link

Please let me know if this helps.
Thanks,
Shane

#1859295

Hey Shane - thanks for your reply!

I tried the jquery submit event, but that event fires before validation has taken place. I need an event for when the toolset cred validation is complete and the form is *actually* being submitted. The submit event basically fires when the submit button is clicked, and if there are validation errors on the form, it still fires. Is there a 'validation complete' javascript event that I could use?

#1859475

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Greg,

The problem is that the validation is done using php which occurs after the form has been submitted.

Right now there isn't a jQuery action that can run after the form submit.

Why not use our Toolset redirect option to redirect the user to the success page after the form has been submitted successfully.

Please let me know if this is ok.

Thanks,
Shane

#1860969

Hey Shane -

I'm using the redirect option, but the problem is that the form takes so long to submit that I need a way to tell them to wait until the redirect happens.

Is there anything you can think of that I can use to determine that the clicking the submit button resulted in the form actually being submitted? Like can I check if the validation error is shown at the beginning of the form, or something like that?

#1861645

Hi, Shane is on vacation this week so I'm taking a look at his tickets. There's no public JavaScript API available for Forms, so there's no event to hook into for validation. If the Form does not use AJAX, you might be able to set up some custom JavaScript that detects whether or not some URL parameter exists when the page loads, then use that detection script to trigger the browser scroll position to update to the top of the Form. That would help inform the User that some validation error has occurred. If the Form uses AJAX, you might be able to use jQuery's global AJAX events to detect Form submission responses and trigger the scrolling manually based on those responses, but these solutions involve custom code that falls outside the scope of support we provide here since there is no public JavaScript API for Forms.

Global AJAX event handlers:
https://api.jquery.com/category/ajax/global-ajax-event-handlers/

Another ticket where a client has shared a custom solution (not supported by Toolset or guaranteed to work):
https://toolset.com/forums/topic/split-hook-into-the-cred-form-success-event/