[Javascript] onChange event not firing at all
David Dorward
david at dorward.me.uk
Wed Oct 20 11:53:45 CDT 2010
On 20 Oct 2010, at 17:49, Andre Polykanine wrote:
> Here's a simple form. For unknown reason the onChange event does fire
> only when the Tab key is pressed (as if it was an onBlur handler).
Because that is what is supposed to happen:
"the event is deferred until the element loses focus."
— http://api.jquery.com/change/
Use a keypress event if you want it to happen on a keypress.
> More than that, the remaining chars number is increasing only by one.
$(this).length is the number of elements in the jQuery selector - which is always going to be 1.
You want something more along the lines of:
remaining = max_length = $(this).val().length;
--
David Dorward
http://dorward.me.uk
More information about the Javascript
mailing list