1

Atleast defining my problem is simple... I have a Input control (Text) and a javascript function, which truncates the Text in the input control to 15 characters. ie if the length exceeds the limit, left(text,15) is set back to the control.

This is handled through onkeyup event...

Now, when user drag and drops the text directly into the Input control, the event is not fired as no keyboard is involved. In that case, which event fires... or how do I execute the javascript function in that scenario.

The King
  • 4,600
  • 3
  • 39
  • 58

1 Answers1

1

Except for onkeyup, try handling onmouseup too. It should trigger when you release your mouse button in the input-box (in other words, when you drop the text).


Edit: Apparently onmouseup only triggers if the mouse button was clicked in the input-box too, but onfocus should trigger when the input-box receives focus when you're dropping the text.

Example:

document.getElementById('elementid').onkeyup  = function()
{
   // Restrict value length to 15 characters
};
document.getElementById('elementid').onfocus = document.getElementById('test').onkeyup;
Martin Nycander
  • 1,309
  • 13
  • 29
  • onmouseup event fires otherwise when a mouse button is released on the Text Box but not when drag and drop happens... I dont know why. – The King Oct 26 '09 at 14:07
  • 1
    In Firefox 3.6, the textarea does not get the focus when text is dropped onto it. – Erik Kaplun Apr 18 '11 at 19:17