views:

361

answers:

4

I'm using some jquery to disable a form submit button after it's been clicked to prevent accidental repeated clicking. This works fine in all browsers except Firefox. In Firefox if the user uses the browser Back button to go back to a page after the submit button disabling has occurred, the submit button is still disabled. Is there any solution to this problem?

A: 

If a browser has caching disabled, then the page will be reloaded as if nothing had happened (no button clicked).

If you want client side, you could use a cookie.

Now, if you have a a server side technology (PHP/Rails), then you could put the value in the session variable.

easement
+2  A: 
$(document).ready(function() {
    $('input[type=submit]', this).attr('disabled', false);

    $('#myform').submit(function(){
        $('input[type=submit]', this).attr('disabled', true);
    });    

});

Using jQuery, this will make the button not disabled upon using the back-button on the browser. Tested on FF 3.5.

Erik
A: 

Probably, you should add autocomplete="off" parameter to your form

<form autocomplete="off">
  <input type="submit" />
</form>
Kirzilla
A: 

Good answer from Kirzilla. It's HTML5 friendly. :)

gohaku