Friday, May 1, 2009

Text Area Maximum Length

/*Text Area Maximum Length

<textarea cols="40" rows="3" id="" wrap="physical"

onKeyUp="return textCounter(this.form.other,this.form.remLen_1,100);"

onKeyDown="return textCounter(this.form.other,this.form.remLen_1,100);" name="other"></textarea>

<input type="text" name="remLen_1" value="100">

*/

function textCounter(field, countfield, maxlimit) {

var textlength = field.value.length;

if (textlength > maxlimit) {

field.value = field.value.substring(0, maxlimit);

} else {

countfield.value = maxlimit - textlength;

}

}

No comments:

Post a Comment