Naturally, when I tried to enter text into the textarea, I just typed it there. But that’s not always what users do. Can you imagine, some users might actually compose text in, say, Microsoft Word and then paste it into a textarea? Maybe they are taking advantage of the spell-checker or grammar-checker. Maybe it’s text that they have composed once, but are submitting to several different sites. Or maybe it’s some reason I can’t even fathom!
When I copy-and-paste text, I highlight it, hit CTRL-c, put my cursor at the destination, and hit CTRL-v. But that’s not always what users do either. And as it turns out, if you right-click and select Paste, neither onKeyDown or onKeyUp are triggered. Adding onBlur and onChange seem to do the trick, though.
Of course, this discovery hasn’t exactly solved the problem: the script we are using simply truncates text that is too long. In Firefox, if your textarea has a scrollbar, it could show the user just the top portion of his or her pasted text. Everything would look OK, and the character count displayed would show, for example, 500 of 500 characters.
I haven’t written a replacement script yet, but something clearly needs to alert the user that text has been truncated. At least, however, I have identified the problem.
2 thoughts on “Users Paste Differently”
I have no idea how long it has been there, but most browsers seem to support an onPaste event, which makes client-side checking for textarea value lengths much more robust.