How to call two events from a single input box

Discussion in 'JavaScript' started by balaa_uk, Sep 24, 2006.

  1. #1
    Hi, I have a input box where I would like to call a() on keypress event and call b() in blur event. How do i do that?.
     
    balaa_uk, Sep 24, 2006 IP
  2. Evoleto

    Evoleto Well-Known Member

    Messages:
    253
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    108
    #2
    The second event it's easy to set: onBlur="b();".

    For the first, you should be aware that key capturing is document-wide - I belive there are some other solutions, but if you want cross-browser compatibility there's no way around. Being document-wide, you will need to combine the keycapturing with the focus events of the input box so you will be capturing only then the input is done in that particular box.

    For implementation, read this and this.

    Good luck! ;)
     
    Evoleto, Sep 24, 2006 IP