Java Script Validation

When we are upload any image on server. Server Throw the Error Image format can't be accept. You can check the Extension of image both way one is JavaScript and another is C#. In this code we are learning how to check format.

You can below code Value is a filename of image with extension.
  1.  var filelength = parseInt(value.length) - 4;    
  2.  var fileext = value.substring(filelength,filelength + 4);    
  3.  if (fileext.toLowerCase()!= '.gif'     
  4.        && fileext.toLowerCase() != '.jpg'     
  5.        && fileext.toLowerCase() != 'jpeg' &&    
  6.        fileext.toLowerCase() != 'bmp' &&     
  7.        fileext.toLowerCase() != 'png')    
  8.  return false;