FineUploader:在onValidate/onValidateBatch回调上添加/更改验证规则 [英] FineUploader: Add/change validation rules on onValidate/onValidateBatch callback

查看:36
本文介绍了FineUploader:在onValidate/onValidateBatch回调上添加/更改验证规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在页面上,使用一些初始验证设置创建了fineUploader放置区.在用户点击上传"按钮之前,一些验证设置可能会更改.如何使fineUploader用新的替换初始验证规则?

On a page, a fineUploader dropzone is created with some initial validation settings. Before the user hits the Upload button, a few validation settings may change. How to make fineUploader to replace the initial validation rules with the new ones?

我有一个应用程序,可以让您制作不同尺寸的广告,并且我想使用qq.ImageValidation来验证图像广告的尺寸.

I have an application that allows you to create ads of different sizes and i want to use the qq.ImageValidation to validate the image ad dimensions.

推荐答案

如何使fineUploader用新规则替换初始验证规则?

How to make fineUploader to replace the initial validation rules with the new ones?

您不能.但是您可以在 submit 事件中调用一个函数可以动态验证文件,并在 validation 选项.

You cannot. But you can call a function within the submit event which can dynamically validate files, and set some "base" validators in the validation option.

validation: {
// set default options such as making sure all uploads are images 
// or within a certain size.
},

onSubmit: function (id, name) {

   var file = this.getFile(id),
       validated = validate(file);
   if (validated) return true;
   else return false;
}

如果此函数返回false,则该项目将被标记为已验证并且不会被上传.如果此函数返回true,则您在选项中设置的验证程序将在之后遍历文件.

If this function returns false, then the item will not be marked as validated and not be uploaded. If this function returns true, then the validators you set in the options will be ran over the file(s) afterwards.

这篇关于FineUploader:在onValidate/onValidateBatch回调上添加/更改验证规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆