Spoonk Spoonk - 28 days ago 4x
Javascript Question

OnKeyUp JavaScript Time Delay?

Hi Again Masters Of The Web :)
Now, I have got a new stupid question, and I am asking to forgive me. I read everywhere about this solution, but didn't find the one that works for me.

I have got:

<input name="domain" type="text" id="domain" onKeyUp="javascript:chk_me();">

All I am asking is how to make this not to check after a button is pressed, but after to say 1000 miliseconds of keyboard inactivity?


Try this:

var timer;
function chk_me(){
   timer=setTimeout(function validate(){...},1000);

In this way every time a key is pressed, the timeout will be deleted and the set again.