469,308 Members | 2,801 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,308 developers. It's quick & easy.

Use .blur() without locking cursor (jQuery)

I have a few text input fields for data entry. I use .blur() for client data validation. Some of the fields requires a little extra validation processing. This creates a long pause (i.e. the cursor is locked) as the user tabs from one input to the next. Is there some way to fire up the .blur() event asynchronously so that the user can continue typing in the next field before the validation process for the previous is completed?
Sep 16 '10 #1

✓ answered by gits

javascript code cannot be executed async, even when you delay it with a timeout the code runs after the specified amount of time ... but it runs first before you could proceed then - the browser needs to be free of the code that does the validation to not only execute this code first - javascript has no multithreading capabilities or similar - with a XMLHttpRequest this could be 'simulated' a bit ...

5 2143
gits
5,390 Expert Mod 4TB
events cannot be fired async - but you could use an async validation by doing that serverside and start a XMLHttpRequest on blur which would send the value to the server which then could be validated there
Sep 17 '10 #2
Thanks, I can do that, but I was hoping to avoid that. What about async a function called inside the event?
Sep 17 '10 #3
gits
5,390 Expert Mod 4TB
javascript code cannot be executed async, even when you delay it with a timeout the code runs after the specified amount of time ... but it runs first before you could proceed then - the browser needs to be free of the code that does the validation to not only execute this code first - javascript has no multithreading capabilities or similar - with a XMLHttpRequest this could be 'simulated' a bit ...
Sep 17 '10 #4
Thanks. Actually the timeout code is working very nicely now. Are you saying that all subsequent work must wait until after the timeout? All I know is that it removes the cursor lag. I'm not sure if there is some side effect you have in mind.
Sep 17 '10 #5
gits
5,390 Expert Mod 4TB
it might delay the code's execution but when it runs then everything has to wait ... so lets say the execution starts 1s later on ... then the timed out code runs and after that the next code runs ...
Sep 17 '10 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Timo | last post: by
reply views Thread by Scott Meddows | last post: by
4 posts views Thread by John please don't spam me! | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.