Jump to content

Prevent repeated clicks on submit button


nbarnum

Recommended Posts

We use the contact form that comes with Prestashop.  The form doesn't have anything to prevent a user from clicking the submit form multiple times.  We've gotten sometimes 18 messages at one time before.  Is there anyway this can be corrected?  I know there's a way to disable to button after clicking it on the client side but I was hoping to also prevent this on the server side.

{literal}
<script>
$(function()
{
  $('#myform').submit(function(){
    $("input[type='submit']", this)
      .val("Please Wait...")
      .attr('disabled', 'disabled');
    return true;
  });
});
</script>
{/literal}

I tried using this code but it prevents the entire form from completing.

Link to comment
Share on other sites

What version of PrestaShop are you using? PrestaShop version v1.6 has code in the PHP file that checks whether the message is the same as the previous message and displays "Your message has already been sent" if it is. I guess your version doesn't have that code?

 

I guess you could put some code on the button itself like onclick="$(this).attr('disabled', 'disabled')".

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...