File Upload Image Type Validate

In the File Upload Image Type Validate script is used to validate all type of images for example validate .gif,.jpg,.png file types.

Demo :



Upload Image :

Example :

Just click in Validate button the java script alert will say 'Please Select Image'. Suppose if you select another file (with out image files are .gif .jpg and .png) and click validate button in the alert will say 'Please select .jpg or .gif or .png file only'.

Code :

If you need to validate image file types following code helpful to you.


function image_validate()
{
  if(document.frm_file_validate.file_upload.value!="")
  {
    if((document.frm_file_validate.file_upload.value.lastIndexOf('.jpg')==-1) && (document.frm_file_validate.file_upload.value.lastIndexOf('.jpeg')==-1) && (document.frm_file_validate.file_upload.value.lastIndexOf('.gif')==-1)&& (document.frm_file_validate.file_upload.value.lastIndexOf('.png')==-1))     {
    alert('Please select .jpg or gif or .png file only');
    document.frm_file_validate.file_upload.focus();
    return false;
    }
  }
}

In the above validate() function have using to validate image types. Which is validate for .gif,.jpg,.jpeg,.png file format images.

Free Download Script:

If you need file upload image type validate click and download from following zip file.

Download -->




Content