Disabling the button after once click

后端 未结 9 1733
遥遥无期
遥遥无期 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:13

    To submit form in MVC NET Core you can submit using INPUT:

    
    

    To make it a button I am using Bootstrap for example:

    
    

    To prevent sending duplicate forms in MVC NET Core, you can add onclick event, and use this.disabled = true; to disable the button:

    
    

    If you want check first if form is valid and then disable the button, add this.form.submit(); first, so if form is valid, then this button will be disabled, otherwise button will still be enabled to allow you to correct your form when validated.

    
    

    You can add text to the disabled button saying you are now in the process of sending form, when all validation is correct using this.value='text';:

    
    

提交回复
热议问题