jQuery configurable-serialize Plugin

by Matt Chisholm <matt (dash) jquery (at) theory (dot) org> & Seth Harris

Visit this plugin's page on plugins.jquery.com. This plugin is released into the public domain.

What does it do?

This jQuery plugin adds configuration options to jQuery's standard serialize() function. Its default behavior is identical to the built-in serialize() function, but it offers two configuration options, emptyValues and emptyCheckboxes.

emptyValues defaults to true. When set to false, it causes serialize to omit form elements with no value. This is useful when you have a form with many optional fields and want to keep the form submission small.

emptyCheckboxes defaults to false. When set to true, it causes serialize to include un-checked checkboxes in the serialized form parameters, with no value. This is useful when you want to explicitly tell your server backend to blank checkbox values.

Demo

Modify the form widgets and see the results of configurable-serialize's serialize() function below:






Results

emptyValues emptyCheckboxes Result
True False
False False
True True
False True