I have the following HTML:
<input id="upload1" type="file" /><br/>
<input id="upload2" type="file" /><br/>
<input id="upload3" type="file" /><br/>
<input id="upload4" type="file" /><br/>
<input id="upload5" type="file" /><br/>
<span id="label" style="color:red; display:none">
Wrong filetype!
</span>
And the following jQuery:
$('input:file').change(function(){
var ext = $(this).val().split('.').pop().toLowerCase();
$('#label').toggle(ext != 'pdf');
});
What I want to do, is only toggle the #label if all 5 of the input:file elements pass the validation (pdf extension only). Or no file selected.
At the moment, if i select a .jpg first, the #label displays, then if i select a .pdf the #label disappears. This is incorrect as there is still a .jpg selected in one of the five input:file elements.
EDIT: Fiddle here