Why have my CFFORM's suddenly broken - using CFFORM in a hosted environment

Previous versions of ColdFusion, ie: pre-CFMX, generated the CFFORM validation JavaScripts on the fly. CFMX differs in that it now included in a seperate file "cfform.js" in the CFIDE/scripts folder.

Unfortunately you might, as I am, be using a shared hosting environment (often called "multi-homed" where, for good reason, the CFIDE folder is not accessible as a web folder in the usual way. Often the hosting provider will password protect the CFIDE folder our move it out of a web accessible folder altogether.

The same thing applies to the CFWDDX tag so if you are having a similar issue the fix is the same(ish).

Step 1:

Upload the CFFORM.JS file (located in your localhost/cfide/scripts folder) to your web site root.

Step 2:

In your "application.cfm" template add the following line of code. You may need to adjust the IP address but try 127.0.0.1 by default as this will usually work in a hosted environment anyway.

<cfparam name="Request.CFFORM_JS_Lib" type="string" default="http://127.0.0.1/cfform.js">

Make sure the CFFORM.JS file is located in your web site root or in a subdirectory (adjust the URL if needed).

Step 3:

Now replace your existing opening CFFORM tag with the following:

<cfform scriptsrc="#Request.CFFORM_JS_LIB#" ...>

The scriptsrc attribute is new to CFMX. Use the other CFFORM attributes (name, enctype, etc) as you normally would except that under CFMX the method="post" attribute has been deprecated and is no longer required except.

Your CFFORMs should now work as they always did previously and you will no longer receive embarrassing JS error alerts.

 

All ColdFusion Tutorials By Author: Peter Tilbrook
  • Password encryption for increased security using keys
    You might have already noticed that even database servers like Microsoft's SQL Server 2000 have no method of hiding even password fields from prying eyes. Instead passwords are stored as plain text. Not good. Even Microsoft Access provides a way to mask fileds you would prefer not to be easily read. Not so SQL Server - and probably quite a few other database servers suffer the same issue. This is easily rectified however using two handy functions built-in to ColdFusion, from at at least version 5.0 and above (I think they were in 4.x also). I've developed the following code using CFMX updated 3.
    Author: Peter Tilbrook
    Views: 37,161
    Posted Date: Monday, April 14, 2003
  • What version of CFMX is my host running?
    As of writing this there are four flavours of CFMX, for Windows at least, floating about. You may know what version YOU are running but what about your hosting provider? Run the code below to find out.
    Author: Peter Tilbrook
    Views: 15,340
    Posted Date: Wednesday, May 7, 2003
  • Why have my CFFORM's suddenly broken - using CFFORM in a hosted environment
    If you are using the CFFORM tag in a shared hosting environment, and why wouldn't you as CF form elements can be very useful, you may now be receiving obscure JavaScript errors when your form loads. Never fear, the solution is a simple fix to an annoying problem
    Author: Peter Tilbrook
    Views: 22,337
    Posted Date: Tuesday, July 8, 2003
  • Getting Coldfusion Server Metrics
    The often forgotten function GetMetricData() function returns the same info as the cfstat utility.
    Author: Peter Tilbrook
    Views: 12,182
    Posted Date: Thursday, June 3, 2004
  • Getting the TimeZone name
    CFML's function GetTimeZoneInfo will give you timezone offsets, and day light savings time information, but if you want the name of the timezone your ColdFusion server is in you can use java's TimeZone class.
    Author: Peter Tilbrook
    Views: 12,696
    Posted Date: Thursday, June 3, 2004
Download the EasyCFM.COM Browser Toolbar!