Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As far as I know, there are no events fired on Object attribute changes (edit: except, apparently, for <code>Object.watch</code>).</p> <p>Why not use event delegation wherever possible? That is, events on the form rather than on individual form elements, capturing events as they bubble up?</p> <p>For instance (my jQuery is rusty, forgive me for using Prototype instead, but I'm sure you'll be able to adapt it easily):</p> <pre><code>$(form).observe('change', function(e) { // To identify changed field, in Proto use e.element() // but I think in jQuery it's e.target (as it should be) }); </code></pre> <p>You can also capture <code>input</code> and <code>keyup</code> and <code>paste</code> events if you want it to fire on text fields before they lose focus. My solution for this is usually:</p> <ol> <li><strong>Gecko/Webkit-based browsers:</strong> observe <code>input</code> on the <code>form</code>.</li> <li><strong>Also in Webkit-based browsers:</strong> observe <code>keyup</code> and <code>paste</code> events on <code>textarea</code>s (they do not fire <code>input</code> on <code>textarea</code>s for some reason).</li> <li><strong>IE:</strong> observe <code>keyup</code> and <code>paste</code> on the <code>form</code></li> <li>Observe <code>change</code> on the <code>form</code> (this fires on <code>select</code>s).</li> <li>For <code>keyup</code> and <code>paste</code> events, compare a field's current value against its default (what its value was when the page was loaded) by comparing a text field's <code>value</code> to its <code>defaultValue</code></li> </ol> <p>Edit: Here's example code I developed for preventing unmodified form submission and the like:</p> <p><a href="https://stackoverflow.com/questions/194101/what-is-the-best-way-to-track-changes-in-a-form-via-javascript#194347">What is the best way to track changes in a form via javascript?</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload