Gary King

Gary King

  • NA
  • 83
  • 207.8k

Preventing multiple Submit button clicks

Jan 13 2012 8:53 AM
I have a rather large web form with btnSubmit event code that can take several seconds to complete.
The problem is that users are clicking the submit button multiple times which causes multiple records to be added to the database.

I found a JS based solution at http://www.codeproject.com/KB/ajax/disable_btn_on_click.aspx which initially seemed to work well.

My form has a number of panels that are initially hidden (it is whilst they are hidden that the above solution works).

However, at least one of the panels must be visible (panels become visible when user clicks Checkboxes - one per panel). When one or more of the panels become visible, the solution does not work (that is to say that the submit button remains enabled).

I'm not sure why this is, but suspect it may have something to do with the submit button's reference changing when panels become visible (I may be totally wrong!)

Can anyone suggest how to get the solution to work, or alternative solutions to prevent multiple submits?

Thanks
Gary

Answers (3)