Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery Enable / Disable Submit Button in IE7

I am using the following code to disable the submit button

$("input[type='submit']").attr("disabled", "disabled");

And this code to re-enable it:

$("input[type='submit']").removeAttr("disabled");

It works fine on all browsers I've tried except Internet Explorer 7. IE7 will disable the button fine, but when it is re-enabled, the button still looks disabled.

This button is enabled and clickable in spite of the cursor and gray color:

IE7 enabled button with disabled appearance

(A colleague had the same trouble with IE8, but I could not reproduce it.)

I have a workaround in place that does the job, but its ugly. I have two buttons, one disabled, one not. To start, I show the disabled one and hide the enabled button.

$("input[type='submit']:first").css("display","inline"); //show disabled
$("input[type='submit']:last").css("display","none");    //hide enabled
...
<input name="Submit" type="submit" value=" Sign In " tabindex=3 disabled>
<input name="Submit" type="submit" value=" Sign In " tabindex=3 >

When my "if" conditions are met, I hide the disabled submit and show the enabled one.

Is there a more elegant CSS or JQ based solution to this problem?

like image 695
Brien Malone Avatar asked Dec 17 '22 10:12

Brien Malone


2 Answers

$("input[type='submit']").prop("disabled", false);
like image 88
Burak Erdem Avatar answered Jan 06 '23 16:01

Burak Erdem


Try

$("input[type='submit']").attr("disabled", "");

or

$("input[type='submit']").attr("disabled", false);
like image 36
lukas.pukenis Avatar answered Jan 06 '23 15:01

lukas.pukenis