HTML input element has a maxlength attribute, which prevents inputting a text longer than the maxlength . Upon pasting a text into the input box, if the text is longer than the maxlength, it will be truncated to the exact length of maxlength. How can I tell if the text was truncated or not please?
Thanks.
Assuming you want to know if the length of the value of an input element is the same as the maxlength of that element, you could do something like this (using JQuery).
This however is not the same as a truncated value, it may simply be that exact length.
If you want to know if a user is still writing after reaching the maxlength, you could use look at the keyup event and whether or not the input is focused. However, to compare the clipboard with your input, you might have to resort to Flash.
In short, there is no good solution.