jQuery validating multiple input:file

Jemba

New Member
I have the following HTML:\[code\]<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>\[/code\]And the following jQuery:\[code\]$('input:file').change(function(){ var ext = $(this).val().split('.').pop().toLowerCase(); $('#label').toggle(ext != 'pdf');});\[/code\]What I want to do, is only toggle the \[code\]#label\[/code\] if all 5 of the \[code\]input:file\[/code\] elements pass the validation (pdf extension only). Or no file selected.At the moment, if i select a \[code\].jpg\[/code\] first, the \[code\]#label\[/code\] displays, then if i select a \[code\].pdf\[/code\] the \[code\]#label\[/code\] disappears. This is incorrect as there is still a \[code\].jpg\[/code\] selected in one of the five \[code\]input:file\[/code\] elements.EDIT: Fiddle here
 
Back
Top