Note that there are some explanatory texts on larger screens.

plurals
  1. POIE8 custom jQuery maxlength onpaste-script for textareas drops value
    text
    copied!<p>I have the following jQuery script in use, which implements a maxLength behaviour for textareas.</p> <p>Here's my code:</p> <p><strong>code deleted</strong> see fiddle instead: <a href="http://jsfiddle.net/G7mA7/2/" rel="nofollow">http://jsfiddle.net/G7mA7/2/</a></p> <p>I am not searching for another script because this usally works fine, but only usally :-)</p> <p>Now the real weired thing bout this. Try my code in IE8 and hold ctrl + v to paste something in a textarea. As you can quickly see after reaching the maxLimit the whole text of the textarea is deleted! If you do it step by step everything works fine.</p> <p>First I thought the next paste event starts before the other is finisched, but as far as I can see this is not the case.</p> <p>So dudes.. why is this happening when I stay on paste, but does not happen when I do it step by step?</p> <p><strong>update</strong> I've forked the fiddle from @thedixon so you can see the effect. </p> <p><a href="http://jsfiddle.net/G7mA7/" rel="nofollow">http://jsfiddle.net/G7mA7/</a></p> <p>Just open it in IE8. Safe a string like "0123456789" into your clipboard, click into the textarea and stay on ctrl + v to paste.. as you can see the text disappears after reaching the limit.</p> <p><strong>update</strong> sorry, had to update the code, because the simple code did not even work in simplest case. It's now a bit complexer, but without the other elements the "step by step" pasting wont work.. but now see for yourself.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload