How to set minSize in Bootstrap Validator

天涯浪子 提交于 2019-12-06 05:19:39

as nghuuphuoc/bootstrapvalidator


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

In the latest code of BootstrapValidator (v0.5.2-dev), the minSize option was implemented.

So you can do the following :

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

Refrences :

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!