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

后端 未结 9 2146
北荒
北荒 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:01

    Best way I found this to work best is if all information is correct on the form then add the attribute to the submit button. Incase user needs to comeback and fill out form again with correct information.

    document.querySelector('.btn').addEventListener('submit',function(){
        if(input.value){
            this.setAttribute("disabled", "true")
        }
    };
    

提交回复
热议问题