Skip Navigation

[Resolved] Validator – add custom function After validation, but Before form submit

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.


This topic contains 4 replies, has 2 voices.

Last updated by caseyJ 6 years, 7 months ago.

Assigned support staff: Waqas.


We have a cred form that uses custom javascript to send entry data to a remote api. We hid the default submit button, and replaced it another to trigger our function.

On success, we call this to submit the form in wordpress:

jQuery( "input[name='form_submit_1']" ).trigger('click');

This validates the form & submits it. Everything works as expected. However, we would like the cred validation to occur before our custom javascript is triggered. Is there a way to put the original submit button back, and just do 'if valid - run our functions' and then submit the form?

If so, please provide a simple example (as we are not experts in javascript).




Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

CRED provides an API to deal with some events behind the scene. However, this isn't a JS API, but is a PHP API based on Word Press standards.

API provides a validation hook, which you can use to validate your form. If error occurs, it returns to the form with relevant error information. But form has to be submitted. Please see


Yes, I've read up on that. Using the PHP API doesn't work for us b/c we need to run our javascript before the page redirects. And Cred is using validation.js to validate the form before submit. So, we are wondering if there is a way to modify the default behavior, so it runs our functions after validation & before submit.



Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Unfortunately, CRED does that behinds the scene, and the JS validation can't be extended. All you need to apply your custom approaches in this regard.

Please let me know if I can help you with anything related.


we figured out how to do it. in case this helps someone else, it goes something like this:


	var allowSubmit = false;
    $('#cred_form_2201_1').submit(function( event ) {

      	var form = jQuery( "#cred_form_2201_1" );
        if (form.valid() && !allowSubmit ) {
			//run our functions
			_ourfunction(test, {
				success: function (data) {
					jQuery( "input[name='form_submit_1']" ).trigger('click');
    				error: function (data) {
		allowSubmit = true;