Set Maxlength to TextArea    

Question: I want to set maximum length to the textarea. I am using following code for the same,but it is not working,
<textarea name="txtDescription" cols=10 rows=3 maxlength=50></textarea>
But it is not working,it takes characters beyond 50.

This solution is re-usable for all text areas via one function and
it doesn't inform the user that he/she is typing too many characters, it prevents them from doing so, sort of like maxlength

The Function:
<script language="javascript" type="text/javascript">
function imposeMaxLength(Object, MaxLen)
  return (Object.value.length <= MaxLen);

<textarea name="myName" onkeypress="return imposeMaxLength(this, 15);" ><textarea>

It's easy... it's a PSACAKE!
Back | Tell A Friend | Search this Site
1998 - 2014
Version 3.23

Send me One Million FREE Guaranteed Visitors