title: JQuery Validate Image Upload File Type
body: <p>I have a JQuery script that validates the upload of avatar images but I need it to prevent the upload of anything <strong>other than PNG, JPG &amp; GIF</strong> images.  Any way of implementing this into the code I have? Here is the code:</p>
  
  <pre><code>$('#addButton').click(function () {
      var avatar = $("#avatarupload").val();
      if(avatar.length &lt; 1) {
          avatarok = 0;
      }
      //ELSE IF FILE TYPE
      else {
          avatarok = 1;
      }
      if(avatarok == 1) {
          $('.formValidation').addClass("sending");
          $("#form").submit();
      }
      else {
          $('.formValidation').addClass("validationError");
      }
      return false;
  });
  </code></pre>