title: jquery: how to remove blank fields from a form before submitting?
body: <p>I have a page with a set of forms on it, used for API testing. For reasons not worth explicating, I generally don't want to include empty fields in the submission to the server. How do I delete empty fields from the data before submitting?</p>
  
  <p>For example, if I have a form with two fields, foo and bar, and the user leaves bar blank, I want the server to see the submission as if the only field were foo.</p>
  
  <p>My first stab at that involved looping through the fields using jquery with</p>
  
  <pre><code>$("form").submit(function() {
      $(this).children(':input').each(...)
  }
  </code></pre>
  
  <p>And removing the field. But that a) didn't work, and b) seems like it would delete the field from the visible form on the page which is not what I want.</p>
  
  <p>Another approach might be to loop through the fields and construct the submit string manually with fields that have values other than "". Will that work? Any better ideas?</p>