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

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

Received on Tuesday, 26 January 2010 05:53:48 UTC