GuitarGod Posted September 10, 2010 Share Posted September 10, 2010 Hi all, I'm having a little problem with JS's "this.value" - it always seems to be one letter behind than the fields actual value. If I may explain: <input type="text" onkeydown="alert(this.value)"> As you can see, everytime a key is entered, the value of the text box should be displayed in a Javascript alert. However, if I entered the letter "M", then a blank JS alert would pop up. If I enter another letter along side the "M", for example "D", then the letter "M" would alert, but not the "D". If I entered a third letter, then the letters "MD" would alert, but not the third letter. So the alert message is always one letter behind. I hope you can understand what I mean. Is there anyway round this so the exact value that I enter is the value that gets alerted? Thanks for any light you can shed on this. Quote Link to comment Share on other sites More sharing options...
Adam Posted September 10, 2010 Share Posted September 10, 2010 Try 'onkeyup'. Quote Link to comment Share on other sites More sharing options...
GuitarGod Posted September 10, 2010 Author Share Posted September 10, 2010 Works! Thank you very much! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.