Skip to content

Instantly share code, notes, and snippets.

@billerickson
Last active January 20, 2021 17:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save billerickson/578828965dc148b502a5 to your computer and use it in GitHub Desktop.
Save billerickson/578828965dc148b502a5 to your computer and use it in GitHub Desktop.
jQuery(document).ready(function($){
// Remove empty fields from GET forms
// Author: Bill Erickson
// URL: http://www.billerickson.net/code/hide-empty-fields-get-form/
// Change 'form' to class or ID of your specific form
$("form").submit(function() {
$(this).find(":input").filter(function(){ return !this.value; }).attr("disabled", "disabled");
return true; // ensure form still submits
});
// Un-disable form fields when page loads, in case they click back after submission
$( "form" ).find( ":input" ).prop( "disabled", false );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment