My form has several inputs like this:
<input type="file" name="imagem_file[]" class="form-control">
<button id="btnProdutoImagem" class="btn btn-info btn-block">Cadastrar</button>
And my Jquery checks to see if the input has been changed like this:
<script>
$(document).ready(function(){
$("#btnProdutoImagem").on('click', function(){
var target = $("input[name='imagem_file[]:first']").val();
if (target.length == 0) {
console.log('Nenhum arquivo selecionado.');
}
})
});
</script>
But this only works if the first input file is changed, if you select the second one does not identify Jquery, how to identify if any one has changed and validate?
If I just leave it like this:
var target = $("input[name='imagem_file[]']").val();
Jquery does not validate as well.