Skip to content

Instantly share code, notes, and snippets.

@Xordal
Last active December 29, 2015 23:59
Show Gist options
  • Save Xordal/7746052 to your computer and use it in GitHub Desktop.
Save Xordal/7746052 to your computer and use it in GitHub Desktop.
Return serialized form without null-value fields
// Удаление null-полей из модели
var cleanedForm = function(form) {
"use strict";
var thisArray = $("#" + form).serializeArray();
$.each(thisArray, function(index, item) {
if (item.value.toString().toLowerCase() == "null") {
delete thisArray[index];
}
});
return thisArray;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment