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