Reputation: 623
I have code that limits number of characters with a sort of "countdown" field that works in real-time as the user types.
Everything works perfectly except when the user "pastes" their text. Only when they click in the field again does it reset and know there are too many characters entered.
Is there a way to make it work on mouseup / out... or interact with a paste by user?
Here is the current code:
<script type="text/javascript">
function textCounter(field,cntfield,maxlimit) {
if (field.value.length > maxlimit)
field.value = field.value.substring(0, maxlimit);
else
cntfield.value = maxlimit - field.value.length;
}
</script>
Upvotes: 0
Views: 1060