Here is a javascript I use (works in NN and MSIE).

<script language="JavaScript" type="text/javascript">
<!--
// This function invoked when user edits one box at a time. After hitting
tab to move 
// to next box or number chars reaching over the max go thru each box and
make sure 
// each box contains valid number of chars (up to max chars) if more than
valid number 
// then prompt for error message and automatically trim off excess chars
function CheckLength(ta,theSize) {
        var m_name = " ";
        /* for progdesc form field */
        if (ta.name == "progdesc" && ta.value.length > theSize) {
                m_name = "Program Description ";
                alert(m_name + " exceeds " + theSize + " chars");
                ta.value = ta.value.substring(0, theSize-1);
                return false;
        }
}
//-->
</script>

<textarea cols="52" rows="20" name="progdesc" WRAP=VIRTUAL onKeyUp="return
CheckLength(this,1040);" onChange="return
CheckLength(this,1040);"></textarea>



in the 'on' events of the TEXTAREA just set the second value to the length
you wish to limit the text area to.  In the example above I'm limiting to
1,040 characters.


Steven Semrau
SRA International, Inc.
Senior Member, Professional Staff
[EMAIL PROTECTED]
[EMAIL PROTECTED]
Com:  (703) 805-1095
DSN:  (703) 655-1095


-----Original Message-----
From: FARRAH NG [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 03, 2001 9:39 AM
To: CF-Talk
Subject: limiting text entry to textarea


I need to limit the maximum number of character entered to a 
textarea box to 100, and i am not too sure how to do it.  Is there
anyone have any idea ? or had done something similar to this before ?

I will appreciate all suggestions.

thanks



--------------------------------------------------------------------------
Global Internet phone calls, voicemail, fax, e-mail and instant messaging.
Sign-up today at http://www.hotvoice.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to