To limit the textarea using javascript, we can use the below simple code which limits the textarea characters.
function textLimit(field, maxlen) {
if (field.value.length > maxlen + 1)
alert('Total Length is only '+ maxlen +' Characters');
if (field.value.length > maxlen)
field.value = field.value.substring(0, maxlen);
}
and the code to be used in the textarea is shown below.
<textarea name='address' cols='28' rows='4' onkeyup="textLimit(this,350)"></textarea>
No comments:
Post a Comment