How to submit form only once after multiple clicking on submit?

后端 未结 9 2213
北荒
北荒 2020-12-13 10:41

I am having problem that when i am trying to submit the form by clicking on the submit button it takes some time to post request during this if i am again click on the Submi

9条回答
  •  遥遥无期
    2020-12-13 11:22

    One solution is to not use an as the submit button, but instead a

    (or ) styled as a button, having an onclick attribute:

    ...
    Submit

    And the submitOnce function would first remove the onclick attribute and then submit the form:

    function submitOnce() {
      document.getElementById('submit-button').removeAttribute('onclick');
      document.getElementById('my-form').submit();
    }
    

提交回复
热议问题