terminal42 / contao-ajaxform

Submit a form through ajax and display error or confirmation message.
14 stars 7 forks source link

Prevent Button from hitting multiple times #27

Closed akroii closed 10 months ago

akroii commented 1 year ago

When you set up a form with multistep page behaviour, it is possible to hit the final submit button multiple times while the form is processing. image After this you would get the current url in the frame.

I'm using it in combination with

Contao: 4.9.33 terminal42/contao-ajaxform: 1.1.3 terminal42/contao-mp_forms: 4.4.0

akroii commented 10 months ago

In hindsight, I think this is a UX/UI feature that a developer should do themselves.

  if(document.querySelector("#ds") !== null){
    document.getElementById("ds").addEventListener("submit",function(event) {
      if(event.submitter.id == "mp_form_pageswitch_108_5"){
        document.getElementById('mp_form_pageswitch_108_5').disabled = true;
        console.log("button disabled");
      }
    });
  }