How to Prevent Users from Submitting a Form Twice

后端 未结 16 997
挽巷
挽巷 2020-12-01 06:59

when user click add button twice, from get submitted twice with same dat

16条回答
  •  情歌与酒
    2020-12-01 07:30

    This is an old question, but I had an issue with my form that doesn't have an answer on here and thought it could be useful as I suspect it is a common issue.

    I'm using jQuery validate on my forms, and if the user tries to submit the form, but the front-end validation prevents the form from being submitted, the submit button is still disabled meaning the user cannot submit the form.

    Expaniding on rogueleaderr's great answer, I added a quick check to make sure there was no front-end error messages before disabling re-submitting of the form:

    It just checks to make sure there are no error classes on screen before disabling the form.

提交回复
热议问题