jquery: how to remove blank fields from a form before submitting?
One way would be to set the “disabled” attribute on those fields, which prevents their values from being serialized and sent to the server: $(function() { $(“form”).submit(function() { $(this).children(‘:input[value=””]’).attr(“disabled”, “disabled”); return true; // ensure form still submits }); }); If you have client-side validation, you’ll also want to re-enable these fields in the event of … Read more