Perhaps you can configure the serializeArray function in jQuery to enable the checkbox if it is not set.
Demo
NOTE. Below is just a draft, please feel free to optimize.
$.fn.serializeArray = function () { var rselectTextarea= /^(?:select|textarea)/i; var rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i; var rCRLF = /\r?\n/g; return this.map(function () { return this.elements ? jQuery.makeArray(this.elements) : this; }).filter(function () { return this.name && !this.disabled && (this.checked || rselectTextarea.test(this.nodeName) || rinput.test(this.type) || this.type == "checkbox"); }).map(function (i, elem) { var val = jQuery(this).val(); if (this.type == 'checkbox' && this.checked === false) { val = 'off'; } return val == null ? null : jQuery.isArray(val) ? jQuery.map(val, function (val, i) { return { name: elem.name, value: val.replace(rCRLF, "\r\n") }; }) : { name: elem.name, value: val.replace(rCRLF, "\r\n") }; }).get(); }
Selvakumar arumugam
source share