As a user types into a textfield, another field generates a new number to reflect each additional letter. For example, "c" yields 1, "ca" yields 3 and "cat" regenerates the number field to, say, 9. The user sees this update as he types in his string. For this we use the ONKEYUP event.

Our problem comes when the user "pastes" a string into the textfield. Pasting doesn't trigger the ONKEYUP event. Were we to use ONCHANGE, we'd lose the letter-by-letter update-and-show-number feature. That's because ONCHANGE only gets the input once the entire string is entered.

Can you suggest code that incorporates the benefits of both the ONKEYUP and the ONCHANGE events, so we could still offer letter-by-letter updates and, in the event of a paste, update the number field based on the entire string?

    Thanks! Can you suggest sample code how I can combine both ONKEYUP and ONPASTE to work together?

      <input type='text' name='stuph' onKupUp="(doSomething()" onPaste="doSomethingElse()">
      
        Write a Reply...