1
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 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 I select according to Jquery does not identify, how to identify if anyone has changed and validate?
If I just leave it at that:
var target = $("input[name='imagem_file[]']").val();
Jquery does not validate either.
I believe that [] in the input name is not something valid
– Sveen