Categories: Report an Issue :

Disabling submit button prevents form submission. Bug?

Showing 1-9 of 9 messages
Disabling submit button prevents form submission. Bug? Lukezilla 2/21/10 11:45 AM
Using Chrome 4.0.249.89 (Official Build 38071), Windows XP Professional.

The following bit of HTML and JavaScript works in Firefox 3.6, but not in Chrome 4.
In both browsers: the button is disabled, preventing the user from hitting it more than once, and the button changes to "Working..."
In Firefox the form is submitted, as expected. In Chrome it just sits there. It seems as if disabling the submit button prevents the form from being submitted.

<form name="go" action="go.html" method="POST">
        <input type="hidden" name="somevalue" value="123" />
        <input type="submit" name="submit" value="Click to Submit" class="submit" onclick="{this.disabled=true; this.value='Working...';}">
</form>

Am I doing something wrong or is this a bug in Chrome?
Re: Disabling submit button prevents form submission. Bug? pcreux 3/1/10 10:17 PM
I have the exact same issue. :-/
Re: Disabling submit button prevents form submission. Bug? greywolf1988 3/15/10 6:35 PM
I have too the same issue
Re: Disabling submit button prevents form submission. Bug? dougaxe1 4/21/10 11:26 AM
I too have the same issue, and I can't seem to find any documentation elsewhere
Re: Disabling submit button prevents form submission. Bug? dougaxe1 4/22/10 7:41 AM
May be related to a webkit bug: https://bugs.webkit.org/show_bug.cgi?id=14443
Re: Disabling submit button prevents form submission. Bug? Jason Hanley 4/22/10 9:25 PM
Confirmed here also. Not good, as this trick is commonly used on e-commerce sites.
Re: Disabling submit button prevents form submission. Bug? Jason Hanley 4/22/10 9:32 PM
You can make it work in Chrome by adding a "this.form.submit();", ie.
onclick="this.disabled=true; this.form.submit(); return true;"
Re: Disabling submit button prevents form submission. Bug? tlloyduk 6/4/10 6:16 AM
What you need to do to fix this is to use the onSubmit tag in the <form> element to set the submit button to disabled. This will allow Chrome to disable the button immediately after it is pressed and the form submission will still go ahead....

e.g.

<form name ="myform" method="POST" action="dosomething.php" onSubmit="document.getElementById('submit').disabled=true;">
...
<input type="submit" name="submit" value="Submit" id="Submit">
</form>
Re: Disabling submit button prevents form submission. Bug? Lepe 7/5/10 9:13 PM
The solution posted above about using "this.form.submit();" on click event, wont work if you are trying to post a form through XHR.
If you are using JQuery, this may solve the problem in any case:

        $("form").each(function() {
                $(this).find("button:submit").click(function() {
                        //$(this).attr("disabled", "disabled"); // Replaced line

                        if($(this).hasClass("disabled")) return false;                
                        $(this).addClass("disabled");
                        return true;
                });
        });

You can easily add style to "button.disabled" now. After getting the XHR response, don't forget to remove the class "disabled" from the button.