I would like to have some functionality by which if i write
<textarea maxlength="50"></textarea>
<textarea maxlength="150"></textarea>
<textarea maxlength="250"></textarea>
it will automatically impose the maxlength on the textArea. If possible please donot provide the solution in JQuery.
Note: This can be done if i do something like this:
<textarea onkeypress="return imposeMaxLength(event, this, 110);" rows="4" cols="50">
function imposeMaxLength(Event, Object, MaxLen)
{
return (Object.value.length <= MaxLen)||(Event.keyCode == 8 ||Event.keyCode==46||(Event.keyCode>=35&&Event.keyCode<=40))
}
copied from another thread
But the point is I don't want to write onKeyPress and onKeyUp every time i declare a textArea.