News:

Looking for documentation? Take a look on our wiki

Main Menu

Ask question disable button on send

Started by frandevelop, August 22, 2022, 13:01:04 PM

Previous topic - Next topic

frandevelop

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

sorry, forgot to comment:
Joomla 3.10.2
Virtuemart 3.8.7

Jumbo!

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);

frandevelop

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);
         });
      });
   });

   
   
');