我想防止用户在.NET MVC中多次提交表单。我尝试了几种使用Javascript的方法,但在所有浏览器中都很难使用。那么,我如何在我的控制器中防止这种情况呢?是否有某种方法可以检测到多个提交?
发布于 2010-11-23 06:26:46
发布于 2011-03-24 04:36:42
为了完成@Darin的回答,如果您想处理客户端验证(如果表单有必填字段),您可以在禁用提交按钮之前检查是否存在输入验证错误:
$('#myform').submit(function () {
if ($(this).find('.input-validation-error').length == 0) {
$(this).find(':submit').attr('disabled', 'disabled');
}
});
发布于 2014-07-29 00:56:39
如果我们使用$(this).valid()
会怎么样
$('form').submit(function () {
if ($(this).valid()) {
$(this).find(':submit').attr('disabled', 'disabled');
}
});
https://stackoverflow.com/questions/4250604
复制相似问题