Author Topic: Ask question disable button on send  (Read 610 times)

frandevelop

  • Beginner
  • *
  • Posts: 18
Ask question disable button on send
« 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?

frandevelop

  • Beginner
  • *
  • Posts: 18
Re: Ask question disable button on send
« Reply #1 on: August 22, 2022, 17:11:14 pm »
sorry, forgot to comment:
Joomla 3.10.2
Virtuemart 3.8.7

Jumbo!

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 856
  • Full-stack Web Developer
    • www.virtueplanet.com
  • VirtueMart Version: Always the latest
Re: Ask question disable button on send
« Reply #2 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.


Code: [Select]
(function($) {
$(function() {
$('form#askform').on('submit', function() {
$(this).find(':submit').attr('disabled', true);
});
});
})(jQuery);

frandevelop

  • Beginner
  • *
  • Posts: 18
Re: Ask question disable button on send
« Reply #3 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);
         });
      });
   });

   
   
');