W3C home > Mailing lists > Public > whatwg@whatwg.org > January 2010

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

From: Kornel <kornel@geekhood.net>
Date: Tue, 26 Jan 2010 13:53:48 +0000
Message-ID: <598F59A5-AC69-4A55-A4DD-22E7BB1C2C76@geekhood.net>
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

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:20 UTC