javascript - jQuery - Compare new value with old value on form submit, across all fields (inputs, selects)? -
i reading answer question, solve problem single field, how watch fields (input, select, radio, etc...) on form?
this have (i'm using delegate, form injects page dynamically):
$('#preferencesbody').delegate('input[type="radio"], select', 'change', function() { var key = $(this).attr('data-key'); var value = $(this).val(); // how old value, , compare current value, if different, call saveuserpreferences? preferences.saveuserpreferences(key, value); });
thanks.
$('#formid :input')
will select input fields (including textarea's , buttons) on form id=formid
so function this..
$('#preferencesbody').delegate(':input', 'change', function() { var key = $(this).attr('data-key'); var value = $(this).val(); preferences.saveuserpreferences(key, value); });
Comments
Post a Comment