Use .blur() without locking cursor (jQuery)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Parmenides
    New Member
    • Jun 2010
    • 5

    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?
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    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

    Comment

    • Parmenides
      New Member
      • Jun 2010
      • 5

      #3
      Thanks, I can do that, but I was hoping to avoid that. What about async a function called inside the event?

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        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 ...

        Comment

        • Parmenides
          New Member
          • Jun 2010
          • 5

          #5
          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.

          Comment

          • gits
            Recognized Expert Moderator Expert
            • May 2007
            • 5390

            #6
            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 ...

            Comment

            Working...