TYPE : 1
<script type="text/javascript" language="javascript">
function SetMaxLength(Object, MaxLen) {
return (Object.value.length <= MaxLen);
}
</script>
<textarea rows="10" cols="80" id="txtNotes" style="resize: none" onkeypress="return SetMaxLength(this, 15);"></textarea>
//style="resize: none" will make textarea fixed size
-----------------------------------------------------
TYPE : 2
function textLimit(field, maxlen) {
if (field.value.length > maxlen) {
while (field.value.length > maxlen) {
field.value = field.value.replace(/.$/, '');
}
alert('Maximum limit exceeded!');
}
}
<textarea rows="10" cols="80" id="txtNotes" style="resize: none" onkeypress="textLimit(this,20)"></textarea>
<script type="text/javascript" language="javascript">
function SetMaxLength(Object, MaxLen) {
return (Object.value.length <= MaxLen);
}
</script>
<textarea rows="10" cols="80" id="txtNotes" style="resize: none" onkeypress="return SetMaxLength(this, 15);"></textarea>
//style="resize: none" will make textarea fixed size
-----------------------------------------------------
TYPE : 2
function textLimit(field, maxlen) {
if (field.value.length > maxlen) {
while (field.value.length > maxlen) {
field.value = field.value.replace(/.$/, '');
}
alert('Maximum limit exceeded!');
}
}
<textarea rows="10" cols="80" id="txtNotes" style="resize: none" onkeypress="textLimit(this,20)"></textarea>
No comments:
Post a Comment