Bypass unchecked radio buttons, unchecked checkboxes and disabled inputs

This commit is contained in:
Salva Machí 2020-01-13 10:24:12 +01:00
parent 37d7d498ec
commit 2ca6c12089
1 changed files with 14 additions and 0 deletions

View File

@ -451,7 +451,21 @@ jQuery( function( $ ) {
var data = {};
$( ':input', fields ).each( function(index, elem) {
var $input = $(elem);
// Bypass non-checked checkboxes and radio buttons.
if (($input.is(':radio') || $input.is(':checkbox')) && !$input.is(':checked')) {
return;
}
// Bypass disabled fields.
if (true === $input.prop('disabled')) {
return;
}
data[elem.name] = elem.value;
});
$( '.variations-defaults select' ).each( function( index, element ) {