Truncate values from multiline textbox after fix length in javascript or How to truncate a string to a certain number of characters,
Example
Suppose you need to update a textbox with a description. Any description over 10 characters is truncated to 10.
<html> <head> <script language="JavaScript"> function maxtitle(txt,maxlength) { if(txt.value.length > (maxlength-1)) { txt.value = txt.value.slice(0,maxlength); return false; } } </script></head> <body> <form name=form1> Enter Name: <input type="text" name="txtNumber1" onkeyup="return maxtitle(this,10);"> </form> </body> </html>