title: How to stop empty input fields from affecting calculations in a form
body: <p>I have a form which calculates the sum and average of a set of user entered values. Users can dynamically add input fields so that they may find the sum and average of as many data values as they wish. I am trying to proof it such that if they happen to add a field but leave it blank, that input field will be ignored in the calculations. When left blank at present, the form returns 'NaN,NaN'. I have tried this</p>
  
  <pre><code>$(':input[value=""]').attr('name', ''); 
  </code></pre>
  
  <p>based on a quick search, but it did not have the intended effect (the form still returns 'NaN,NaN'. </p>
  
  <p>The calculations are performed when the user clicks a button using the following jQuery</p>
  
  <pre><code>$(".calc").click(function() {
     $("input[type=text]").each(function() {
      arr.push($(this).val());
      sum += parseInt($(this).val());       
    });
  
    var n = arr.length;
    var AVG = (sum / n);
    alert(sum + "," + AVG);
    arr = [];
    sum = 0;
  });
  </code></pre>
  
  <p>Any suggestions?</p>