Hello,
I’m using a script on a form that limits the number of charatcers used in a textarea field. I currently have set the textarea to a limit of 255 characters. I have noticed that when a user does a copy and paste of content that is more than 255 characters, the extra characters will be added to the textarea field. But if a user types in the conetent, it will max out at 255.
Is there a way to setup the script or the textarea so if a user types or does a copy and paste, the content will max at 255 only?
-Javascript-
<!– Begin
function textCounter(field,cntfield,maxlimit) {
if (field.value.length > maxlimit) // if too long…trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update ‘characters left’ counter
else
cntfield.value = maxlimit – field.value.length;
}
// End –>
-Textarea Code-
<textarea name=”quick_bio” wrap=”virtual” cols=”51″ rows=”5″
onKeyDown=”textCounter(document.form.quick_bio,document.form.remLen1,255)”
onKeyUp=”textCounter(document.form.quick_bio,document.form.remLen1,255)”>
</textarea>
Thanks;