Matt
Matt

Reputation: 1257

How to set minSize in Bootstrap Validator

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

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!'
                        }
                    }
                }
            }
        });
    });

Is there a way to set it for minSize?

Upvotes: 2

Views: 2158

Answers (2)

Pasindu Jayanath
Pasindu Jayanath

Reputation: 943

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.'
    }
}

Upvotes: 2

Arkni
Arkni

Reputation: 1177

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 :

Upvotes: 0

Related Questions