javascript textbox call event when value changes

Posted by Senica Gonzalez on Stack Overflow See other posts from Stack Overflow or by Senica Gonzalez
Published on 2010-05-13T19:02:55Z Indexed on 2010/05/13 19:14 UTC
Read the original article Hit count: 368

Filed under:

I have a textbox, and whenever the value of the box changes, I want to check and see if 20 digits have been entered.

I thought that I would use the onChange event, but this seems to be interpreted as the onBlur event on IE.

So then I thought I would use onKeyDown, but the problem comes in if the user wants to paste a value into the field, then the function never gets called.

There are no other form boxes so I can't rely on onBlur or expect that they will change focus ever.

How do I do this?

I just want to evaluate the value of the textbox everytime the value of the textbox changes.

<input type="text" onKeyDown="myfunction()">

© Stack Overflow or respective owner

Related posts about javascript-events