mattquantic
Programmer
Hi. Is it possible to restrict the number of lines in a text area using JS?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
onKeyPress="count_change(this,400);"
function count_change(textObj, MaxLen)
{
Msg = textObj.value;
Msglen= Msg.length;
//maximum length of our textarea
// MaxLen=400;
if (Msglen > MaxLen )
{
textObj.value=Msg.substring(0,MaxLen);
textObj.blur();
//next line is to pop-up a warning box - not essential
}
// next line is if we want to return the users focus to the textarea.
textObj.focus();
}