Support

Home Forums Event Espresso Premium Preventing Double Submit on Registration Page

Preventing Double Submit on Registration Page

Posted: June 12, 2014 at 7:31 am

Viewing 9 reply threads


Clair Mason

June 12, 2014 at 7:31 am

Hello everyone,

I am currently having a problem with users clicking the submit button repeatedly for my events, which sometimes creates 3 or more registrations while the next page is loading. Is there a way to stop this? I know this can be done with javascript, but am unsure where to put it into the code.

Thank you.


Lorenzo Orlando Caum

  • Support Staff

June 12, 2014 at 10:44 am

Hi Clair,

I ran some testing on this in the current version of EE3 but could not reproduce the issue.

Could you let us know what page this is happening on?


Lorenzo


Josh

  • Support Staff

June 12, 2014 at 11:34 am

Hi Clair,

Normally what would happen is the prior registration would be overwritten because it’s all happening in the same PHP session. That said, if the server isn’t configured to allow PHP sessions, then you might see the double entries in the database.

The first thing to check would be if PHP Sessions are enabled, and the Event Espresso > System Status page has this information.

The other thing you can try is swapping out the contents of the event-espresso/scripts/validation.js file with the following:

$jaer = jQuery.noConflict();
	jQuery(document).ready(function($jaer) {
	jQuery(function(){
		//Registration form validation
		jQuery('#registration_form').validate({
			submitHandler:function(form){
				alert("Please wait for the registration form to process");
       			$('.btn_event_form_submit').attr('disabled','disabled');
   			}
		})
	});
});

You can try the above with or without the alert on line 7. The alert alone would likely prevent a second submission.


Clair Mason

June 12, 2014 at 11:55 am

Hi Lorenzo and Josh,

Thank you for the quick replies. Lorenzo this is happening on all of our event pages the [ESPRESSO_EVENTS] short-code.

Josh there is a sessions save path and session name in PHP Sessions. Your fix does work, however I don’t like the extra popup warning. Is there a way just to disable the button after the first click?

Please go to http://intensity.club/event-registration/?ee=4244 to see an example, I clicked the register button multiple times and got multiple registrations.

Thank you


Josh

  • Support Staff

June 12, 2014 at 1:27 pm

Hi Clair, the code I gave you should disable button after the first click *if the form passes validation*. If it disabled it after the first click only, then people wouldn’t be able to continue if they didn’t fill out a required form.

The alert on line 7 is optional and you can remove line 7. I suggested earlier to try it with and without the alert.


Clair Mason

June 13, 2014 at 6:46 am

Josh,

I removed the alert and I am still able to get multiple submissions. Any other ideas?


Josh

  • Support Staff

June 13, 2014 at 8:35 am

Can you point us to a registration form that’s currently active so we can investigate further?


Clair Mason

June 13, 2014 at 9:41 am

http://intensity.club/event-registration/?ee=3792

Thank you.


Josh

  • Support Staff

June 13, 2014 at 10:22 am

Hi Clair,

Please review and change the code in the validation script to what follows:

$jaer = jQuery.noConflict();
	jQuery(document).ready(function($jaer) {
		jQuery('form .btn_event_form_submit').css("color", "green");
	jQuery(function(){
		//Registration form validation
		jQuery('#registration_form').validate({
			submitHandler:function(form){
       			jQuery('form input[type=submit]').attr('disabled','disabled').css("color", "red");
       			form.submit();
   			}
		})
	});
});

Please note a few adjustments to the script and that there’s a few places where we add the .css method to change the color of the button text from green (submit button active) to red (submit button is disabled).

The color changes are intended to be temporary to help verify the script is working. You can remove those after testing.


Clair Mason

June 13, 2014 at 10:25 am

Amazing. Works perfectly now Josh. Thank you!

Viewing 9 reply threads

The support post ‘Preventing Double Submit on Registration Page’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso