1) A very simple way to handle this is to start with the onChange event:
<textarea id="yourTextArea" onchange="this.value.length = Math.min(this.value.length, 250)"></textarea>
The main drawback here is that the text field will not be updated until the focus leaves the text field.
2) You should be able to adapt the above example to the form validation function that runs in the form of the onSubmit event.
<script type="text/javascript"> document.forms[0].onsubmit = function() { document.getElementById("yourTextArea").value.length = Math.min(this.value.length, 250); } </script>
3) If you want to perform this check on the server side, you just need to get the value of textarea and truncate it.
string validText = yourTextArea.Value.Substring(0, 250);
Jeff meatball yang
source share