1<input type="file" id="image" accept="image/*" onChange="validate(this.value)"/>
2
3function validate(file) {
4 var ext = file.split(".");
5 ext = ext[ext.length-1].toLowerCase();
6 var arrayExtensions = ["jpg" , "jpeg", "png", "bmp", "gif"];
7
8 if (arrayExtensions.lastIndexOf(ext) == -1) {
9 alert("Wrong extension type.");
10 $("#image").val("");
11 }
12}
13