Introducing New plugin sFileTypeChecker to validate file type while uploading. sFileTypeChecker is light weight jQuery plugin checks either user has selected valid file or not when user select file using HTML file control. The basic principle of this plugin is to check the file uploaded by user is valid file having extension mensioned by user and error messages for HTML elements in JavaScript.

Read More:

sSwitch – JQuery Plugin For Sliding Toggle Switches

How To Create Simple JQuery plugin

sFileTypeChecker - JQuery Plugin

Integrate sFileTypeChecker JQuery Plugin Into HTML Page

This tutorial shows you how to set up a sFileTypeChecker plugin in HTML page. You need basic level knowledge of JavaScript, JQuery and HTML.

 Demo Download

Directory Structure

index.php

Basic usage is quite straightforward. Select the file inputs you wish to have validated, and invoke sFileTypeChecker.

Include JavaScript and CSS Files

Download and Include the jQuery and sFileTypeChecker plugin JavaScript at the bottom of >body< tag. Download JQuery library in js folder. You need to have basic skill of JQuery Framework and JavaScript Scripting language.

Add Form Controls In Page

Add file input box to upload file having id ctlImage. We will use id in later part at time of
initialization.



Invoking Plugin

Invoke sFileTypeChecker plugin with extension and functions. We have used $('#ctlImage') to invoke plugin on file control.

extensions: Holds array of extension which should be allowed in file upload.
Eg,

success: function(){}: If user uploads valid file than success() function will execute. Here, You can write bunch code if valid file selected.

error: function(){}: If user uploads invalid file than error() function will execute. Here, You can write bunch code if invalid file selected.

Plugin verifies uploaded file’s extension is exists in plugin extension parameter or not. When user select a file, Plugin will imidiatily check that uploaded file is either valid or not. If uploaded file has allowed extension than success() will call. If file is not valid than error() will be called.

Full Code

This Plugin also helps to beginers to create simple JQuery plugins. It supports all the modern browsers such as Google Chrome, Mozilla Firefox, Safari, Opera and Internet Explorer >V11



Read More:

sSwitch – JQuery Plugin For Sliding Toggle Switches

How To Create Simple JQuery plugin

How To Implement Infinite Scroll Using JQuery, Ajax and PHP

Integrate Google Prettify in Html Page

Verify Your Server Meets PayPal Payment Gateway Requirements

Integrate google reCAPTCHA in your website

Leave a Reply

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

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">