0

Till this day I lived in a world where browser prevent multiple form submit by default when form is submited. How is it possible that now I need to write this

// Prevent multiple form submit
activityForm.submit(function(e) {
    $(this).find('input[type="submit"]').prop('disabled', true);
});

to prevent multiple form submit? I dont understand it.

Čamo
  • 3,863
  • 13
  • 62
  • 114
  • Then you lived in a vastly different world than I did. If the server and connection is fast, you might not get the chance, but on a slower connection, you can always submit over and over again while the submission is running and has not yet loaded the result. Be careful when you disable the field. If the server expects to see $_POST["mySubmitButtonName"] to run, it will not if you disable it. Instead set a data attribute of a flag. Of course if you AJAX, then you will have to also handle multiple clicks – mplungjan Jun 21 '23 at 07:58
  • Try to make another PHP File that will handle your POST and after inserting to your database, it will redirect to your form... that also solved my problem too.... –  Jun 21 '23 at 08:01
  • @NagonusLrak no this does not solve the problem. – Čamo Jun 21 '23 at 08:39
  • 1
    I used $(window).on("beforeunload", function() {}); which disable the buttons – Čamo Jun 21 '23 at 08:41

0 Answers0