jqExtension - jQuery file type validation

What is jqExtension?

jqExtension is a very light weight jQuery plugin to validate the file type (extension) at client-side. jqExtension decreases developer’s burden of file type validation. It is easy to use and can be extended. If you have any suggestion or idea to improve it, or have found a bug, please post a comment.

What jqExtension do?

  • Checks whether field type is file.
  • Validate against allowed extensions.
  • Displays error and success messages.
  • Allow user to add custom message.
  • Allow user to set array of extensions to be allowed.

How to use jqExtension?

1. Download the plugin

2. Include jqExtension.js along with jQuery

<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="jqExtension.js"></script>

3. Call jqExtension function

(function ($) {
  $('#file1').jqExtension();
  $('#file2').jqExtension({
    allowed: 'doc,docx,rtf,odt',
    validMessage: 'Validated!',
    invalidMessage: 'Invalid selected file.'
  });
})(jQuery);

Options

Name Description
allowed Specifies which files to be allowed for validation. Default value: jpg,jpeg,png,tiff
validMessage Display a message when file is valid. Default value: Valid file :)
invalidMessage Display a message when file is valid. Default value: Invalid file :(

Demo / Example / Download

Demo

Download

 

You might also like