var extensions = ["image/jpeg","image/png","image/gif"]; if(extensions.indexOf("myfiletype") === -1){ alert("Image must be .png, .jpg or .gif"); }