Disabling the button after once click

后端 未结 9 1732
遥遥无期
遥遥无期 2020-11-28 09:32

I need to disable a button once it\'s clicked so the user can\'t click it more than once. (My application is written in MVC ASP.NET, I\'ve done this in a normal ASP.NET appl

9条回答
  •  悲&欢浪女
    2020-11-28 10:18

    If when you set disabled="disabled" immediately after the user clicks the button, and the form doesn't submit because of that, you could try two things:

    //First choice [given myForm = your form]:
    myInputButton.disabled = "disabled";
    myForm.submit()
    
    //Second choice:
    setTimeout(disableFunction, 1);  
    //so the form will submit and then almost instantly, the button will be disabled  
    

    Although I honestly bet there will be a better way to do this, than that.

提交回复
热议问题