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?
In this article, we will see how to use keyup with a delay in jQuery. There are two ways to achieve the same: Approach 1: Using the keypress(), fadeIn(), delay() and fadeOut() methods in the jQuery library and clearTimeout() and setTimeout() methods in native JavaScript.
Use a variable to store the timeout function. Then use clearTimeout() to clear this variable of any active timeout functions, and then use setTimeout() to set the active timeout function again.
To cancel a setTimeout() method from running, you need to use the clearTimeout() method, passing the ID value returned when you call the setTimeout() method.
Try this:
var timer; function chk_me(){ clearTimeout(timer); timer=setTimeout(function validate(){...},1000); }
In this way every time a key is pressed, the timeout will be deleted and the set again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With