View Full Version : script reads input value one step back

02-18-2005, 08:46 PM

I would like to know exactly what the length of an input is after someone updates the control. Not after the focus has moved on, but while the element has focus. The method I'm using now seems to fire before the control is actually updated, thus the value.length seems to be behind a step.

At first I just thought I must be using the wrong event, that onchange or onkeyup must be what I was looking for. After some trial and many many errors, I have decided that the events are not my problem, but my perception.

I'm in need a fresh pair of eyes.

It just occurred to me, but this may not be the correct place to post this..

Should it be moved to the javascript forum?

02-21-2005, 10:36 PM
Change your event handler to onkeyup.

if(formInputs[i].id=="myId") formInputs[i].onkeyup = function(){myFunction(this)};

02-21-2005, 11:17 PM
I feel like a tard... I swore I tried that.

Thank you very much for pointing out my oversight. It works just fine now.