Disable Submit Button

J

Jeff

I have a payment form with a submit button. A large percentage of users
double-click the submit button thus submitting their payment information
twice. I would like to use javascript to disable the submit button once
it's been clicked, yet still have the form submit. I can do this in ASP
2.0, however, ASP.Net seems to be adversely affected if you disable the
submit button. Here's how I have it set up...

The submit button is a WebControls.Button
In the Page_Load event I attach an "onclick" javascript event handler to
disable the submit button.

i.e. btnSubmit.Attributes.Add("onclick", "document.Form1.btnSubmit.disabled
= true; return true;")

The problem with this is once the button is disable the form will not
submit. If I change it to the following it will work, however, the button
will not be disabled.

i.e. btnSubmit.Attributes.Add("onclick", "document.Form1.btnSubmit.disabled
= false; return true;")

Any ideas on how to accomplish this?

Thanks!
 
B

bruce barker

btnSubmit.Attributes.Add("onclick",
"window.setTimeout('document.Form1.btnSubmit.disabled= true;',10);");

but this recommend. the submit fails (post lost on internet), the user can
not refire it. if they hit refresh, the button will be enabled. you should
store a transaction guid in a hidden field and tack that it has been
processed. you should also code for two running at the same time.

-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top