Disable button on form submission

前端 未结 17 1671
伪装坚强ぢ
伪装坚强ぢ 2020-12-01 00:13

I have a button that I would like to disable when the form submits to prevent the user submitting multiple times.

I have tried naively disabling the button with java

17条回答
  •  北海茫月
    2020-12-01 01:13

    Disable the button at the very end of your submit handler. If the validation fails, it should return false before that.

    However, the JavaScript approach is not something that can be relied upon, so you should have something to detect duplicates on the server as well.

提交回复
热议问题