TextArea character limits

The following code can be used to limit the number of characters one can enter into an HTML TextArea field.

<FORM action="nextpage.asp" method=POST name="myForm">

<TEXTAREA rows=3 cols=40 name="txt_project_description"></TEXTAREA>
<font size="1">
 Max 1000; characters remaining:  <input value="1000" size="3" name="msgCL" disabled>

<script language="JavaScript">
var supportsKeys = false
function tick() {
 if (!supportsKeys) timerID = setTimeout("tick()",1000)

function calcCharLeft(sig) {
 clipped = false
 maxLength = 1000
 if (document.myForm.txt_project_description.value.length > maxLength)
   document.myForm.txt_project_description.value = document.myForm.txt_project_description.value.substring(0,maxLength)
   charleft = 0
   clipped = true
   charleft = maxLength - document.myForm.txt_project_description.value.length
   document.myForm.msgCL.value = charleft
   return clipped



You might also like...


Super Tal Always working hard!!


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“There are 10 types of people in the world, those who can read binary, and those who can't.”