0

Is it possible to change the behavior of the submit button on the contact form, so that it will only allow to click one time?

Now when you fill in the form and click multiple times on the submit button, it wil sent the contact form and email multiple times.

Is there a way to reduce this to only 1 time?

We are running Magento 1.9.3.9

  • Do you have a custom form or a custom theme? – Haim Nov 18 '18 at 13:35
  • @Haim Yes it is a custom theme, but the contact form template is just the same as default. – Henk Z Nov 18 '18 at 16:36
0

Natively, in the Magento contact form, you can send only one form in the same time, if you are using a custom contact form or custom form you can just disable the double click on that button like the code bellow, if it's an AJAX form, you need to custom this code:

app/design/frontend/{theme}/{name}/template/contact/form.phtml

$(document).ready(function () {
     $("#buttonId").on('click', function() {  
           alert('Clicked'); // for test
           $(this).prop('disabled', true);
           $(this).css('cursor', 'not-allowed'); //additional
     });
});

JSFIDDLE

  • Thanks a lot! I tried that, it does disable the button, but it does not sent the form anymore. So it seems to break the form code. – Henk Z Nov 18 '18 at 16:37
  • Maybe you have some js error but this piece of code should not prevent the validation ! – PЯINCƏ Nov 18 '18 at 23:00
  • Thanks, well your code does work and block the button, but it does not validate anymore. So we can not sent the form and we do not have any JS errors. – Henk Z Nov 19 '18 at 7:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.