I have the following fields coming from the database:
<?php
while($peListar = mysqli_fetch_object($sqlListar){
.....
$listar .= "<td style='".$fundo."'><input type='text' name='ValorI[]' class='md-form-control' value=''></td>";
$listar .= "<td style='".$fundo."'><input type='text' name='ValorII[]' class='md-form-control' value=''></td>";
$listar .= "<td style='".$fundo."'><input type='text' name='ValorIII[]' class='md-form-control' value=''></td>";
$listar .= "<td style='".$fundo."'><input type='text' name='ValorFinal[]' class='md-form-control' value=''></td>";
.....
}
?>
But I would like to count how many empty fields it has, that is, how many fields were not entered by the user. It is understood that I do not want a field validation;), but only count the total of how many fields that were not filled. I tried using the code below, but it did not work:
....
$(\"[name^='ValorI']\").on(\"input\", function(){
.....
var myForm = this.form;
var vazios = 0;
for(var i = 0; i < myForm.elements.length; i++) {
if (myForm.elements[i].value === \"\")
vazios += 1;
}
alert(vazios);
....