Pasting instead of typing text into input field with character limit javascript -
Pasting instead of typing text into input field with character limit javascript -
i have code limits number of characters sort of "countdown" field works in real-time user types.
everything works except when user "pastes" text. when click in field 1 time again reset , know there many characters entered.
is there way create work on mouseup / out... or interact paste user?
here 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>
try maxlength property:
<input type="text" maxlength="10"> javascript character limit paste
Comments
Post a Comment