SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Dec 2011
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Rapid Keystroke - unexpected result

    Dear All,

    I have a Jquery script employing some regex to valid some input. This works fine except if I type very rapidly the script gets confused.

    I have tried to apply setTimeout without success.

    Is there a way of buffering the input so that I can deal with each key stroke in turn? or simply discard any keystroke that occurs between the keyup event and the completion of it's event handler?

    Regards

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,527
    Mentioned
    84 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by codepuppy View Post
    I have a Jquery script employing some regex to valid some input. This works fine except if I type very rapidly the script gets confused.
    It's typically a bad idea to validate on a per-keystroke basis. Have you tried validating on the onblur event instead, which triggers when someone moves away from the field?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •