469,646 Members | 1,692 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,646 developers. It's quick & easy.

Disable Submit Button

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!
Nov 18 '05 #1
3 2885
Check out this, in the Tips & Tricks section of http://aspnet101.com:
http://aspnet101.com/aspnet101/tips.aspx?id=81

David Wier
MCP, MVP ASP.NET, ASPInsider
http://aspnet101.com
http://aspexpress.com
"Jeff" <a@a.com> wrote in message
news:Os****************@TK2MSFTNGP12.phx.gbl...
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!

Nov 18 '05 #2
btnSubmit.Attributes.Add("onclick",
"window.setTimeout('document.Form1.btnSubmit.disab led= 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)
"Jeff" <a@a.com> wrote in message
news:Os****************@TK2MSFTNGP12.phx.gbl...
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!

Nov 18 '05 #3
Hi Jeff,

Have you had a chance to check the other member's suggestions and resources
or have you got any further ideas on this issue? If you have any other
questions, please feel free to post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

14 posts views Thread by Sinity | last post: by
6 posts views Thread by GD | last post: by
6 posts views Thread by jack-e | last post: by
16 posts views Thread by Barry Gilmore | last post: by
4 posts views Thread by Patrick Flaherty | last post: by
6 posts views Thread by millw0rm | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.