禁止form重复提交
2024-08-29 19:07:17
$("form").submit(function () {
console.log("提交了");
$("input:submit").attr("disabled", "true");
setTimeout(function () {
$("input:submit").removeAttr("disabled");
}, 3000);
});
网上看到老外写的
// jQuery plugin to prevent double submission of forms
jQuery.fn.preventDoubleSubmission = function() {
$(this).on('submit', function(e) {
var $form = $(this); if ($form.data('submitted') === true) {
// Previously submitted - don't submit again
e.preventDefault();
} else {
// Mark it so that the next submit can be ignored
$form.data('submitted', true);
}
}); // Keep chainability
return this;
}; //Use it like this
$('form').preventDoubleSubmission();
最新文章
- 【Java EE 学习 28 上】【oracle学习第二天】【子查询】【集合运算】【几种数据库对象】
- Eclipse中的文件导航插件StartExplorer
- Codeforces Round #172 (Div. 2)
- centos安装gitlab
- nodejs技术面试问题整理
- 纯css3代码写下拉菜单效果
- navagationController 的子控制器如何取消右滑返回
- Java面向对象程序设计--与C++对比说明:系列2(类机制)
- Wpf ListBox数据绑定实例1--绑定字典集合
- MVC WebApi 用户验证 (2)
- requireJS 源码(二) data-main 的加载实现
- SpringBoot yml 配置
- windows下安装oracle11g测试是否成功与监听器问题和网页控制台登录
- Centos修改时间为24小时制
- JavaScript中直接量和变量
- Eloquent JavaScript #02# program_structure
- [转] 关于 Ceph PG
- C++单例模式的实现及举例
- 20135220谈愈敏Blog5_系统调用(下)
- Android学习系列(7)--App消息通知机制