Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Coldfusion textarea - maxlength validation

Posted on 2009-02-19
Medium Priority
Last Modified: 2013-12-20
Hello experts.
I need a help with validating (serversite) a textarea where i want to allow maximal 1000 characters.
Here is my code:
<cfif Form.mytexarea NEQ "">
Question by:Panos
  • 2
LVL 16

Accepted Solution

duncancumming earned 2000 total points
ID: 23684838
<cfif Len(Form.mytextarea) GT 1000>
<!--- it's too long --->

LVL 19

Expert Comment

ID: 23684851
it can be done by JS.
function charAlert(textField)
      if(textField.value.length > 1000)
            /* must be > 1000, not == 1000 or else the substring statement on the next line will cause the function to run again if the user dismisses the alert by pressing the 'enter' key rather than clicking 'OK'. */
            textField.value= textField.value.substring(0,1000)
            // set field's value equal to first five characters.
            /* move cursor out of form element to keep it from placing itself at position zero, causing an overwrite of the first character */
            alert("You reached the maximum number of characters allowed");
then you apply this to the textarea
as onblur="charAlert (document.formname.textAreaname)"

Author Comment

ID: 23685096
Hi duncancumming:
Your code is working
Hi erikTsomik.
Thank you for your help too but  i was asking for a server side validation.

Author Closing Comment

ID: 31548914
Thank you again for your help

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
The purpose of this video is to demonstrate how to make a WordPress Site faster and smaller in size by cleaning up the database. This will be demonstrated using a Windows 8 PC. Plugin WP Optimize will be used. Go to your WordPress login page. T…
The purpose of this video is to demonstrate how to Test the speed of a WordPress Website. Site Speed is an important metric of a site’s health. Slow site speed can result in viewers leaving your site quickly and not seeing your content. This…
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question