Wednesday, February 15, 2012

jQuery restrict upload file types

  var  ExtensionList = ['jpeg', 'jpg', 'png', 'gif', 'bmp'];

           jQuery("#file").change(function () {

               if (jQuery.inArray(jQuery(this).val().split('.').pop().toLowerCase(),  ExtensionList  ) == -1) {

                   alert("Only \'jpeg\', \'jpg\', \'png\', \'gif\', \'bmp\' are allowed.");
  jQuery(this).val('');

               }
               });

No comments:

Post a Comment