When a value is entered in an input field, I want to count how many input fields in that row have a value in total.
<div class="row">
    <input type="text" class="input input1" />
    <input type="text" class="input input2" />
    <input type="text" class="input input2" />
</div>
<div class="row">
    <input type="text" class="input input1" />
    <input type="text" class="input input2" />
    <input type="text" class="input input2" />
</div>
I'm trying following but I think problem is with the loop.
$('.input').keyup(function () {
    var field = $(this).parent().children('.input');
    var count = 0;
    $(field).each(function (i) {
        var len = $(field).val().length;        
        if (len > 0 ) {
            count++;
        }
    });
  alert(count);
});
JSFiddle link: http://jsfiddle.net/18cpotw6/
 
     
     
     
    