views:

38

answers:

3

I have a text input :

<input type="text" onkeydown="processText(this)" />

I have a processing function :

function processText(sender)
{
  console.log(sender.value);
  /// processing....
}

But then I check my value, its content hasn't been updated yet. How can I do that?

+2  A: 

Use onkeyup instead :

<input type="text" onkeyup="processText(this)" />
Canavar
+1 My opinion is this: if one key event type fails, try the other two.
karim79
A: 

try onkeyup

http://www.w3schools.com/jsref/jsref_onkeyup.asp

Josh

Josh
A: 

If onkeyup is too late for your needs, you'll need to look at the key code of the event and then do something with the character that may or may not be added to the text box. Take a look at the DOM event reference or at the way jQuery handles it or the way Prototype handles it.

Jim Puls