我在我的页面中使用了Jquery File Upload(http://blueimp.github.io/jQuery-File-Upload/)和Bootstrap validator(https://github.com/nghuuphuoc/bootstrapvalidator),如果表单有效,我只需要在服务器上上传文件,因此我覆盖了Jquery-File-Upload的默认提交功能,如下所示
$(document).ready(function() {
$('.fileupload').fileupload({
url: '/upload',
autoupload: false,
dropZone: $(".fileuploadzone"),
submit: function (e) {
$(document).bootstrapValidator('validate');
if ($(document).data('bootstrapValidator').isValid()) {
return true;
}
else {
return false;
}
}
});
$('.fileupload').bind('fileuploadfinished', function (e, data) {
submitForm();
});
});它适用于第一次单击提交按钮(“有效”或“无效”),但即使表单是有效的,之后也不起作用。我的意思是既不执行验证也不执行文件上传过程。请帮帮我!
发布于 2014-07-09 06:44:30
我认为您只需要在每次提交表单后重置引导验证器。
$('.fileupload').bootstrapValidator('resetForm', true);发布于 2015-08-24 11:59:22
我对你也有同样的问题,
**如果提交事件回调返回false,则不会启动上传请求。(enter link description here)
这是我的解决方案。当提交回调返回false时,启动按钮被禁用,我尝试删除提交回调中的“禁用”属性,它对我来说工作得很好。
submit: function(){
//---invalid--
$('button.start').removeAttr('disabled');
return false;
}祝好运。
https://stackoverflow.com/questions/23381998
复制相似问题