Tips and Tricks HQ Support Portal › Forums › WP eMember › WP eMember Troubleshooting › How to prevent double submission of registrations?
Tagged: double click, Multiple submissions
- This topic has 4 replies, 2 voices, and was last updated 11 years, 3 months ago by admin.
-
AuthorPosts
-
August 6, 2013 at 5:07 pm #9438mattrubinsteinMember
Hi there
I’d like to prevent users from double-submitting registration forms, either by clicking the “Register” button twice, or by pressing Return/Enter on the final field and THEN clicking the “Register” button. It takes a moment for anything to happen after the first submission, and during this time it’s apparently possible to click the button again. Then two registration forms seem to be submitted, and the second one fails because the username is now already taken; and instead of logging in the user and redirecting to the welcome page (which I’ve enabled), we are left on the registration page with the errors.
I’ve looked on the internet for Javascript solutions and have tried to fiddle around with the _onSubmitEvent function in jquery.validationEngine.js, but I can’t seem to both disable the “Register” button AND still get the form to submit on a single click.
Is there a simple fix?
August 7, 2013 at 7:26 am #56970mattrubinsteinMemberJust to follow up on this, I seem to have solved the problem for now by inserting the following code at the beginning of the _onSubmitEvent function:
Code:var now = new Date().getTime();if ((this.beenSubmitted) && (now – this.beenSubmitted < 3000))
{
return false;
}
else
{
this.beenSubmitted = now;
}So this disables any submission within 3 seconds of the last submission. Is this likely to have negative repercussions or is there a better way?
Thanks
Matt
August 7, 2013 at 8:13 am #56971adminKeymasterHi Matt, What you have done is pretty good and should work fine but I think we can do a little better. I like the idea of disabling the button after the first click so I am going to try to create a little eMember addon that disables the register button when it is clicked.
August 9, 2013 at 9:57 am #56972mattrubinsteinMemberThanks Key Master, that sounds good. Maybe some kind of “Please wait” like with the fancy login form would be useful too? And the other problem I was having with disabling the button was re-enabling it again if the validation fails. I’ll leave it with you!
August 11, 2013 at 2:23 am #56973adminKeymasterThe following little addon should do the job:
http://www.tipsandtricks-hq.com/wordpress-membership/disable-button-after-form-submission-848
-
AuthorPosts
- You must be logged in to reply to this topic.