Q:

formvalidation validate only if there is file uploaded

Hi I am using this plugin formvalidation and I am new with this, I have a form with file upload and I want to check if there is a file being uploaded and if there is I will validate this to accept (jpeg,png,gif).  and if there is none I will not validate. 
<form id="myform">
  <div class="form-group">
    <label for="fname">First Name</label>
    <input type="text" class="form-control" id="name" name="fname" placeholder="Name">
  </div>
  <div class="form-group">
    <label for="pic">Upload here</label>
    <input type="file" id="pic">

  </div>
  <button type="submit" class="btn btn-default">Submit</button>
</form>

Thank you in advance. 

A:

You need data-fv-file-type option for FormValidator. 

The allowed MIME type, separated by a comma. 
  For example: Setting image/jpeg,image/png,application/pdf only allows to upload JPEG, PNG image and PDF document. 

Use it like data-fv-file-type="image/jpeg,image/png,application/gif" to validate file extensions while uploading. 
Also, remember to enable the validator by setting data-fv-file="true"
Example
<input type="file" class="form-control" name="avatar"
            data-fv-file="true"
            data-fv-file-extension="jpeg,png"
            data-fv-file-type="image/jpeg,image/png"
            data-fv-file-maxsize="2097152"
            data-fv-file-message="The selected file is not valid" />

