OnKeyPress problem.

Discussion in 'HTML & Website Design' started by mahmood, Nov 4, 2007.

  1. #1
    I try the following code to get the value of a textbox:
    <input type='text' OnKeyPress='alert(this.value)'>
    PHP:
    The problem is that I always get the word minus last letter.

    For example:
    User enters "A", alert returns "".
    User enters "B", alert retuns "A".
    User enters "C", alert returns "AB".

    I have tried OnKeyUp and OnKeyDown as well.
    Is there any event that I can use to get the whole word and not one letter less?
     
    mahmood, Nov 4, 2007 IP
  2. JeffHood

    JeffHood Peon

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The 'onchange' event should supply the input's value after the keyboard event that caused it.
     
    JeffHood, Nov 4, 2007 IP