W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2011

Event for form element changes (onvaluechanged)

From: Glenn Maynard <glenn@zewt.org>
Date: Thu, 7 Apr 2011 21:46:23 -0400
Message-ID: <BANLkTi=CnyyfB+kyzawMOt4kD99j35rk8g@mail.gmail.com>
To: www-dom@w3.org
The onchange event is only fired when an element loses focus.  This
optimization may have made sense when Javascript engines were so slow that
running scripts on each input was a bad idea, but it's a hassle now.  Many
interfaces today update as the user types.

This requires jumping some hoops, since there's no way to catch everything
that might change an input box.  Even if you watch onkeypress, oncut and
onpaste, you'll miss things like Chrome's clear-input button.  (WebKit also
doesn't fire onkeypress consistently.)  The only reliable option is to set a
repeating timer to check the value continuously, which is wasteful.

A "valuechanged" event should be fired after the value changes for any
reason.  To handle multiple items changing at once (radio boxes,
form.reset()), it should be async.  (This name makes the most sense for text
inputs, but the event should apply to the same elements that onchange does.

(This differs from textinput.  textinput is only fired when text is entered,
not when it's removed; textinput is fired before the value changes, not
after; and textinput doesn't apply to all form inputs, just text.)

-- 
Glenn Maynard
Received on Friday, 8 April 2011 01:46:51 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:14:07 GMT