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

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -