VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: frandevelop on August 22, 2022, 13:01:04 PM

Title: Ask question disable button on send
Post by: frandevelop on August 22, 2022, 13:01:04 PM
Hello,
I'm having issues with proudmart form, the form submission is somewhat slow and users double click the submit button and this results in multiple email submissions. I have tried to disable the button using javascript without success, can you help me?
Title: Re: Ask question disable button on send
Post by: frandevelop on August 22, 2022, 17:11:14 PM
sorry, forgot to comment:
Joomla 3.10.2
Virtuemart 3.8.7
Title: Re: Ask question disable button on send
Post by: Jumbo! on August 22, 2022, 17:39:24 PM
You can add the following Javascript to your template to disable the submit button on the form submission.


(function($) {
$(function() {
$('form#askform').on('submit', function() {
$(this).find(':submit').attr('disabled', true);
});
});
})(jQuery);
Title: Re: Ask question disable button on send
Post by: frandevelop on August 30, 2022, 12:05:45 PM
It has worked, thank you very much.  ;D Add it in the script declaration in case someone needs it.

$document->addScriptDeclaration('
   jQuery(function($){
         $("#askform").validationEngine("attach");
         $("#comment").keyup( function () {
            var result = $(this).val();
               $("#counter").val( result.length );
         });
   });
   
   jQuery(function($) {
      $(function() {
         $("form#askform").on("submit", function() {
            $(this).find(":submit").attr("disabled", true);
         });
      });
   });

   
   
');