View Single Post
Old 01-11-2013, 10:32 AM   PM User | #2
niralsoni
Regular Coder

 
Join Date: Mar 2008
Location: London
Posts: 129
Thanks: 1
Thanked 31 Times in 31 Posts
niralsoni is an unknown quantity at this point
Its because you are invoking the "onKeyUp" event that the function call starts immediately.

Well, "OnKeyUp" is the right event, but how your code will come to know that user has finished entering the text ?

For that you need to track a specific key. If that key is hit, that means user has finished entering the text. Normally we call this specific key as the "Enter key".

So, onkeyup, you track which key was pressed. If its "Enter key", then only you start processing your code.

something like -
Code:
var key = event.which || event.keyCode;
if(key == 13) { // 13 is the keycode for enter key
// your piece of code here...
}
Hope it helps you out...

Regards,
Niral Soni
niralsoni is offline   Reply With Quote