<textarea class = "max10" rows = "3" cols = "20"></textarea>
<textarea class = "max5" rows = "3" cols = "20"></textarea>
<script type = "text/javascript" src = "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.1.min.js"></script>
<script language="javascript" type="text/javascript">
//Restrict text while typing
$("textarea[class*=max]").live("keypress", function () {
var maxLength = $(this).attr("class").replace("max", "");
return $(this).val().length <= maxLength - 1;
});
$(document).ready(function () {
//Truncate Text on paste
$("textarea[class*=max]").bind('paste', function () {
var textarea = $(this);
var maxLength = textarea.attr("class").replace("max", "");
setTimeout(function () {
textarea.val(textarea.val().substring(0, maxLength));
}, 100);
});
});
</script>