I have file input fields in a group as shown below. I would like all of them to be required.
<div class="Fieldset FileUpGroup">
<span class="Legend">File Upload Group: (required)</span>
<input name="fileUploads[]" type="file">
<input name="fileUploads[]" type="file">
<input name="fileUploads[]" type="file">
</div>
I have the following jQuery to validate, but it only validates the first.
$('.FileUpGroup').each(function() {
if($(this).find('input[type=file]').val() == '') {
Response('- Upload file not selected!', true);
$(this).addClass('Error').fadeOut().fadeIn();
return false;
}
else {
$(this).removeClass('Error');
}
});
Thank!
source
share