I am trying to disable / enable the save button based on changing form elements. But when the values of the hidden input field change when the button is pressed, the save button does not change.
Below is my code. I am trying to serialize old form values and compare with changed form values. But hidden registered values cannot be serialized, I think.
function toggleSave() {
$('form')
.each(function () {
$(this).data('serialized', $(this).serialize())
})
.on('change input', function () {
$(this)
.find('button.Save')
.prop('disabled', $(this).serialize() == $(this).data('serialized'))
;
})
.find('button.Save')
.prop('disabled', true);
}
The code below works great for all forms except when there are hidden fields. Can someone suggest a solution.
Note. Hidden fields are filled in using the "Select pop-up window" button. ## Title ##