Simplest way to disable button on submission of a form?

前端 未结 5 1984
执念已碎
执念已碎 2020-12-15 04:10

I\'ve been trying to find the \"right\" way to prevent double submits of forms. There are lots of related posts on SO but none of them hit the spot for me. Two questions b

5条回答
  •  离开以前
    2020-12-15 04:39

    You could try using the following code:

    $(document).ready(function(){
       $(".once-only").click(function(){
          this.submit();
          this.disabled = true;
          return true;
       });
    });
    

提交回复
热议问题