Skip to content

Instantly share code, notes, and snippets.

@maxkostinevich
Created December 29, 2015 19:23
Show Gist options
  • Save maxkostinevich/961e148527e20a784c89 to your computer and use it in GitHub Desktop.
Save maxkostinevich/961e148527e20a784c89 to your computer and use it in GitHub Desktop.
Submit empty checkbox
/* Add before submit action to fix checkbox issue
Change value to "off" for not-checked checkboxes and check them.
In this case value "off" (instead of original value) will be stored.
*/
$('form#post').submit(function(e) {
$('#some-wrapper input[type=checkbox]:not(:checked)').each(function(){
var curItem=$(this);
curItem.val('off');
curItem.prop('checked', true);
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment