Image File content type client side validation in Java Script

Try the following code as a java script.......
=================================================================
function fileUploadValidation(){
if(document.getElementById('file1').value != ''){
          var fileName  = document.getElementById('file1').value;
          var ext = fileName.substring(fileName.lastIndexOf('.') + 1);
          if(ext == "gif" || ext == "GIF" || ext == "JPEG" || ext == "jpeg" || ext == "jpg" || ext == "JPG" || ext == "png" || ext == "PNG" ){
                 return true;              
            }else{
             alert("Upload Gif, Jpg or Png images only!");
             document.getElementById('file1').value="";
             return false;
          }
}
===============================================================

Comments

Popular posts from this blog

Read Images from a xlsx file using Apache POI

Read Excel using Apache POI - Exception in thread "main" org.apache.poi.poifs.filesystem.OfficeXmlFileException:

Struts 2 : Warning :No configuration found for the specified action: 'Login.action' in namespace: '/'