title: Compare old values against the new values of Form
body: <p>I have a form with several fields, one of which is "counter", that gets changed constantly. When the form is edited I need to track if some fields are changed and set the "counter" field  to the number of modified fields up on submission. For example, if the old value of counter is 10 and field1, field2 and field3 are modified, then on form submit counter should be incremented to 13.</p>
  
  <p>Below is what I'm attempting to do just for one field but its not working correctly. I also need to check not only one field but a few other fields too. Any help is appreciated. Thanks!</p>
  
  <pre><code>$(document).ready(function(){
      var oldVal = getOldValue("field1");
      var oldCounter = parseInt(getOldValue("Counter"));
      var curCounter;
  
      $('field1').change(function(){
          var newVal= $(this).val();
  
              if(oldVal.val() == newVal.val()){
                  curCounter = oldCounter +1;
                  setField("Counter", parseInt(curCounter));
              }
  
      });
  
  });
  </code></pre>