How to validate files using bootstrap validator

bootstrapValidator.js plugin gives client side validation without page refresh. We can use simply. validator.js plugin we can add validation in our PHP project, or any framework like laravel framework, codeigniter framework, symphony framework etc. This is very interesting and simple. You may also like How to Remote call using bootstrap validator and How to validate bootstrap form using jQuery.

bootstrapValidator.js Plugin

<script src=""></script>


<form role="form" method="post" id="registervalidation" enctype="multipart/form-data">
    <div class="form-group">
        <label>Passport <span class="required"> * </span></label><br />
        <input type="file" name="passport" tabindex="15">
    <div class="form-group">
        <button class="btn btn-primary" type="submit">Submit</button>

jQuery Code

<script type="text/javascript">
    $(function () {
            message: 'This value is not valid',
            fields: {
                passport: {
                    validators: {
                        file: {
                            extension: 'jpg,pdf',
                            maxSize: 5 * 1024 * 1024, // 5 MB
                            message: 'Please upload a .pdf or .jpg file - max. size 5MB'
                        notEmpty: {
                            message: 'Please select Passport File'


Leave a Reply

Your email address will not be published. Required fields are marked *