Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable button with jquery ie8

Status
Not open for further replies.
Aug 23, 2004
174
0
0
US
I'm trying to disable a button when clicked using jquery. In firefox it works fine in ie the form wont submit. Here is the code:

$('#continue').click(function(){
$(this).attr("disabled","disabled");
});
 
When you say "the form won't submit" - are you trying to submit it by clicking on the (now disabled) submit button? If so, surely the reason is because you've just disabled the button?

Anyway - try this instead:

Code:
$('#continue').click(function(){
     $(this)[0].disabled = true;
});

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
I'm trying to submit the form with the button. Since the button is being disabled after it was clicked I don't understand why the first click won't post the form. And the fact that it works fine in firefox but not ie is a little strange.
 
Hi

jkjoe said:
Since the button is being disabled after it was clicked I don't understand why the first click won't post the form.
Yes, after the click, but before the button's default action is performed. Try to set the disabling to be performed after a short delay.

Feherke.
 
What if I added an onsubmit to the <form> to disable the button?

Basically I'm trying to stop users from clicking a submit button twice. Is this the best way to go about it?

Thanks for the help.
 
Hi

jkjoe said:
Basically I'm trying to stop users from clicking a submit button twice. Is this the best way to go about it?
Client-side solutions should be used only to improve the navigation experience. To ensure data/server consistency/integrity you can only trust server-side code. ( If you are using PHP, see thread434-1516762 for a related discussion and a link to an implementation. )


Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top