Hit submit Twice

Results 1 to 3 of 3

Thread: Hit submit Twice

  1. #1
    Join Date
    Dec 1969

    Default Hit submit Twice

    When a user clicks the submit button on a page it submits form info to a response page. Sometimes it takes several seconds for the client to see the response page. A transaction is getting created once this submit button is hit. <BR> Just for grins the user hits the button again and sends through a duplicate transaction.<BR> Is there a way of stopping them from doing this? I do use a javascript alert that populates right when they submit. But this still doesn&#039;t prevent the issue from happening all the time. especially if the network is slow.

  2. #2
    Join Date
    Dec 1969

    Default RE: Hit submit Twice

    Try to Do a javascript form.button.disabled = true in the onclick event or onmousedown event. That should work all the time, it works for me.

  3. #3
    Join Date
    Dec 1969

    Default Won't work in all browsers...

    NS 4, for example, doesn&#039;t *HAVE* a disabled property, at all.<BR><BR>A universal way would be to set a flag (just a global JS variable) and then, if the flag is set, don&#039;t allow the submit.<BR><BR>Something like this:<BR><BR>&#060;SCRIPT Language="JavaScript"&#062;<BR>var alreadySubmitted = false;<BR><BR>function validate( frm )<BR>{<BR> if ( alreadySubmitted ) return false; // don&#039;t allow resubmit<BR> ... other form validation ...<BR><BR> ... assuming all validation passed ...<BR> alreadySubmitted = true;<BR> return true;<BR>}<BR>&#060;/SCRIPT&#062;<BR><BR>&#060;FORM ... onSubmit="return validate(this);"&#062;<BR>...<BR>&#060;/FORM&#062;<BR><BR>***************<BR><BR>You could *also* set the disabled property--makes it clearer to the user--but I&#039;d put code like this in if you are expecting any NS browsers.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts