[whatwg] [Input type=submit] "Disable" after submitting

Kornel kornel at geekhood.net
Tue Jan 26 05:53:48 PST 2010


On 26 Jan 2010, at 13:40, Adam Shannon wrote:

> I'm sure you know this, but there is always this simple way.
>
> <input type="submit" value="Submit" onclick="this.disable=true;" />

No, it's wrong. It may not submit the form, because submit button will  
be disabled before submission takes place.

And even in case it does submit, it becomes incredibly annoying when  
submission fails for some reason (e.g. temporary loss of network  
coverage) — user won't be allowed to retry submission.

This is much better IMHO:

onclick="var t=this; setTimeout(function(){t.disabled=true},1);  
setTimeout(function(){t.disabled=false},5000)"

-- 
regards, Kornel



More information about the whatwg mailing list