title: how to determine onChange event triggered by browser
body: <p><strong>Situation:</strong> I have a form for the user to change their profile. </p>
  
  <p>The form has input fields with event listeners attached for the <code>onchange</code> event so I can tell if the user has made any changes to the form. One of those fields is a password field. </p>
  
  <p>In the case where the browser is set to remember passwords, when the form loads, it fills in the password field and triggers my listener.</p>
  
  <p><strong>Workaround:</strong> </p>
  
  <p>I have set a timeout to reset my dataChanged flag after the page loads. Not very elegant. It seems that crawling the event.callee.caller stack is not recommended, non-standard, and unlikely to distinguish user- from browser-initiated events.</p>
  
  <p><strong>Question:</strong> </p>
  
  <p>Is there a way I can determine events triggered by the user interaction (and javascript) only?</p>
  
  <p>I don't want to <em>cancel</em> the event though, I just want to <em>ignore</em> it.</p>
  
  <p><strong>Clarification on choice of event:</strong></p>
  
  <p>This code is in our form-handling js library used throughout numerous applications. We need to know if the field has actually changed its contents so we can warn the user on leaving the form that data has not been saved. It is also used to trigger recalculation of other co-dependent fields.</p>
  
  <p>Using onkeyup/onkeypress will trigger when the user presses non-editing keys like Tab, cursor-arrow, Shift etc. We want to avoid having to store the contents as loaded, and compare that to the content after onkeyup to determine whether the contents have actually changed.  </p>
  
  <p>Browsers also trap conditions where the user edits the field, changes their mind and presses ESC or CTRL-Z - onchange is not triggered. Event onkeypress fires many times during that process.</p>
  
  <p>Therefore we would want to stick to onchange as the event of choice since it designed for our purpose - fire when content actually changes, once only when user exits the field.</p>