Reputation: 8280
Is there a way to add an event listener to an input where by the focus changes from onfocus
to something like off focus
Basically i have an event listener assigned to my input box using key up
, this then calls my server to check if the username is taken already in the database.
The problem is - this will call every time the user presses a letter, i would rather wait until they are no longer focussed in the input box to check the database, so i can reduce the amount of calls?
What would the best option be for event listening to do this ? As it seems silly to check when user is still typing in the box.
I currently have:
mydiv.addEventListener("keyup",name_exist_validation(),false);
Upvotes: 1
Views: 5149
Reputation: 516
Other sites eg Wordpress use a timer aswell as the Blur event as sdespont said.
Upvotes: 0
Reputation: 14025
Event name Blur
: https://developer.mozilla.org/en-US/docs/Web/Reference/Events/blur
<element onblur="SomeJavaScriptCode">
Upvotes: 6