本文介绍了如何在Bootstrap验证程序中设置minSize的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图弄清楚如何使用Bootstrap Validator插件为文件上传设置minSize.

I'm trying to figure out how to set the minSize for a file upload using Bootstrap Validator plugin.

给出以下代码,我可以设置maxSize maxSize,但不能设置minSize

Given the following code, I can set the maxSize maxSize, but not minSize

$(document).ready(function () {
        $('#test').bootstrapValidator({
            live: 'enabled',
            fields: {
                fileupload: {
                    validators: {
                        file: {
                            extension: 'png',
                            type: 'image/png',
                            maxSize: 1024 * 1024,
                            message: 'The selected file is not valid, or the size is not large enough!'
                        }
                    }
                }
            }
        });
    });

是否可以将其设置为minSize?

Is there a way to set it for minSize?

推荐答案

nghuuphuoc/bootstrapvalidator

validators: {
    file: {
        extension: 'png',
        type: 'image/png',
        minSize: 1024*1024,
        message: 'Please choose a png file with a size more than 1M.'
    }
}

这篇关于如何在Bootstrap验证程序中设置minSize的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 00:12