I am currently trying ot find a way to use jquery to validate if a a file is in picture format (jpeg,jpg,bmp,gif,etc). I have been able to figure out if the input is empty or not with simple .length comparison. How would I be able to check the file type and only accept valid picture formats.
Emtpy or not input:
if ($.trim($('#textInput').val()).length == 0) {
alert("Should Not Be Empty!");
}
Given a file input:
For more extensive file-type filtering, you should ideally use server-side validation.