SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Thread: onInputChange ?

  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2010
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    onInputChange ?

    hi all, i was wondering what may be the best solution to detect a change in value of an input box. Right now im currently using onKeyUp, which is having various problems. firstly, it appears "laggy" because the event only fires when the key goes Up. secondly, if someone were to right-click paste, it would seriously break my script.

  2. #2
    Non-Member Kalon's Avatar
    Join Date
    Aug 2010
    Location
    At my computer
    Posts
    2,012
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2010
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    doesn't onchange activates when the "focus" of the textbox changes?

  4. #4
    Non-Member Kalon's Avatar
    Join Date
    Aug 2010
    Location
    At my computer
    Posts
    2,012
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can't remember. what happened when you tried it?

  5. #5
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,716
    Mentioned
    103 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by Pacerier View Post
    doesn't onchange activates when the "focus" of the textbox changes?
    No, onchange only triggers when the content changes. So if you tab in to the field, write some stuff, then click or tab out, the onchange event only triggers when you leave the field.

    Perhaps you're looking for the onkeypress event instead, if you're wanting to capture each individual keystroke?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  6. #6
    SitePoint Enthusiast
    Join Date
    Aug 2010
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    however the problem i face with onkeypress is that if the user rightclick-paste, my script wouldn't detect it, is there a solution?

  7. #7
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,716
    Mentioned
    103 Post(s)
    Tagged
    4 Thread(s)
    Not really, no. There's only a limited amount of control that you can have over your user.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  8. #8
    SitePoint Enthusiast
    Join Date
    Aug 2010
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    as in a "fix", the current solution i can think of is to put the same logic in onclick as well


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
  •