Detecting form error in Coldfusion

Posted on 2007-10-02
Last Modified: 2013-12-24
Hey All,

        I want to detect a coldfusion form error and handle it gracefully.  Basically a text area field in a form has its input capped via javascript at 7000 characters and the associated database field has a 7000 character limit.  The problem is that some users have javascript disabled on their browser and thus may go over the character limit; resulting in an error page being displayed (Error Executing Database Query.  [Macromedia][SQLServer JDBC Driver][SQLServer]String or binary data would be truncated. )  
      Rather than having this occur, is there a away to detect the error and gravefully handle it; as in displaying a page that says something to the effect of "this field has too many characters, the limit is 7000 and you have input 7210; please press back and reduce the fields content"  etc.   Thank you very much.

Question by:andrewaiello
    LVL 10

    Accepted Solution

    in the server side

    <cfif len(form.textField) gt 7000>
        <!--- display error message here and re-display input form --->
    LVL 1

    Author Comment

    Yes; that will work.  Thanks.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Suggested Solutions

    Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
    Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    794 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now