按钮启用
"Enabling" you ask? Yes. We all know how to disable the submit upon form submission and the reasons for doing so, but what about re-enabling the submit button after an allotted amount of time. After all, what if the user presses the "stop" button immediately after submitting the form? They'd be screwed. Why not re-enable the submit button after an allotted amount of time so that the user may re-submit?
您问“启用”吗? 是。 我们都知道如何在提交表单时禁用提交功能以及这样做的原因,但是如何在分配的时间后重新启用提交按钮呢? 毕竟,如果用户在提交表单后立即按下“停止”按钮怎么办? 他们会被搞砸。 为什么不在指定的时间后重新启用提交按钮,以便用户可以重新提交?
MooTools JavaScript (The MooTools JavaScript)
window.addEvent('domready',function() {
var subber = $('submit');
subber.addEvent('click',function() {
subber.set('value','Submitting...').disabled = true;
(function() { subber.disabled = false; subber.set('value','Resubmit'); }).delay(10000); // how much time? 10 seconds
});
});
Of course, this isn't ideal in all situations. It is, however, a nice touch if your system can accommodate for it.
当然,这并非在所有情况下都是理想的。 但是,如果您的系统可以容纳它,那将是一个不错的选择。
Update: Upon submission, the button's message changes to "submitting..." and once enabled, the message changes to "Resubmit." Thank you to Facundo Corradini for the suggestion!
更新:提交后,按钮的消息更改为“正在提交...”,启用后,该消息更改为“重新提交”。 感谢Facundo Corradini的建议!
按钮启用