表单提交前,判断webuploader是否上传
function busUpLoadImg(postUrl,id) { .......//省略部分不用修改 uploader.on('uploadSuccess', function(file) { $('#' + file.id).addClass('upload-state-done'); //验证是否上传上传 oSuccess = true; }); //回调函数验证是否上传 var oSuccess = false; return function(){ return oSuccess; } }
<input type="text" /> <input type="submit" onclick="subMit()" />
function subMit(){ fn1 = busUpLoadImg("postUrl",1); fn2 = busUpLoadImg("postUrl",2); if(!(fn1() && fn2())){ layer.msg("请上传图片",{time:1500}); return false; } }