Link to home
Start Free TrialLog in
Avatar of Nigel-SA
Nigel-SA

asked on

ColdFusion 8 - Required field not working on web, but works on local system

Hi, When I run the coldfusion file below with requirements to check the boxes before continuing, on my vista PC using CF8 local developer, everthing works fine - getting the popup window with description saying that I need to check before I can go next. However, when I download to web (link below) it does not give a prompt concerning unchecked boxes.  Any help will be much appreciated.  The ISP is using CF8.

http://www.svmgreen.com/employappl/HireEmployReq1.cfm

using CFFORMS....

<cfinput type="checkbox"  name="transportation" value="transportation" label="transportation" required="yes" message="Please check, have reliable transportation"/>
Avatar of _agx_
_agx_
Flag of United States of America image

CFFORM uses javascript to validate the required fields.  If the javascript file is not accessible the validation doesn't work.  That appears to be the problem with your site.  Notice you get an http 404 error if you try and access one of the javascript files
http://www.svmgreen.com/CFIDE/scripts/cfform.js

See this technote on how to fix the issue
http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_18653&sliceId=2
> CFFORM uses javascript to validate the required fields.

_Your_ CFFORM uses javascript to validate the required fields.
try to use js validate function

function validate()
{
var foundCount = 0;
for(i=0;i<document.getElementsByTagName("input").length;i++)
{
if(document.getElementsByTagName("input")[i].type == "checkbox")
{
if(document.getElementsByTagName("input")[i].checked == true)
{
foundCount++;
}
}

}


if(foundCount ==0)
{
alert("please check ");
return false;
}
else
{
return true;
}
}
the above one checks if user had checked atleast one check box
you should copy the /cfide/scripts (usually located on the server at c:\inetpub\wwwroot\cfide\scripts\)folder into a new directory within your webroot. In CF8 you can actually change the name of the folder to whatever you want and then specify the new folder name in coldfusion administrator if you are concerned that. but for now if you just copy that cfide/scripts/ folder and all it's contents to your webroot everything will work fine.
> copy that cfide/scripts/ folder and all it's contents to your webroot everything will work fine.

Yes that's one of the options in the technote mentioned above

http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_18653&sliceId=2
* Copy the /CFIDE/scripts directory into the webroot of the new site.
I clicked on the tech note and couldn't see anything all I can see is:

TechNote
cfform errors with ColdFusion MX on multihomed servers

TechNote DetailsLast Update: 05-12-2005
ID: tn_18653
Browser: All
 
Permanent Link: http://www.adobe.com/go/tn_18653 
Products Affected: ColdFusion
 
I have been having that problem with the adobe tech notes for along time now..
The kb section of the site seems to be down a lot lately, but I can view it with both firefox and IE.  Though it did throw a javascript error in IE.

Here is most of the article

http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_18653&sliceId=2
cfform errors with ColdFusion MX on multihomed servers

Issue
When running ColdFusion MX in a multihomed environment,cfform may not work correctly. The symptoms can include:

JavaScript runtime errors
404 errors for the /CFIDE/scripts/cfform.js file
Required attribute validation does not occur
In ColdFusion 5, cfform generated inline JavaScript code to perform validation. In ColdFusion MX, that JavaScript is kept in a file instead and included where needed. The file, /CFIDE/scripts/cfform.js, may not be available in a hosted environment or if multiple websites have been defined on the server.


Solution
To resolve the issue, use one of the following solutions:

Put a copy of the cfform.js file into a directory in your webroot and use the scriptSrc attribute of thecfform tag to reference it.
<cfform
   scriptSrc=/mysite/scripts/cfform.js>
...</cfform>

Create a virtual directory within your website configuration to point to the /CFIDE/scripts directory under the default website.

Copy the /CFIDE/scripts directory into the webroot of the new site.

Looks like it works in firefox... maybe it's an IE7 thing...give points to _agx_ if it works for you.

it doesn't say anything in the article about the ability in CF8 to specify a new folder name other than /cfide/scripts, which is a cool new feature for admins that like to obscure their directories.
I tried it with IE6 so it may well be an IE7 problem.

> it doesn't say anything in the article about the ability in CF8  to specify a new folder name
> other than /cfide/scripts, which is a cool new feature for admins that like to obscure their directories

Yes, they need to update that technote.  That does sound like a neat feature.  I haven't used it.  What's the benefit in this case (ie with javascript files)?



the benefit is that you can put all the scripts into any directory name you want then set the directory path in CFadminstrator instead of having to do:

<cfform
   scriptSrc=/mysite/scripts/cfform.js>
...</cfform>

everytime you use cfform in your application, also there a ton more tags that use the scripts directory now with all the ajax enhancements, so it would be a real pain if you had to set that scriptsrc variable with every cfmenu,cfform,cfdiv, etc tag in your code


Also, to give you an idea of how much more CF8 uses the cfide/scripts folder:

In previous versions of CF the directory contains 2 files cfform.js and wddx.js

In CF8 the directory contains 1,887 files and 250 folders
> In CF8 the directory contains 1,887 files and 250 folders

Wow.  Now thats a huge increase.  

> it would be a real pain if you had to set that scriptsrc

True.  But even in MX7 you don't have to do that.  You could a) create a virtual directory within your website configuration to point to the /CFIDE/scripts directory under the default website or  b) copy /CFIDE/scripts to the webroot. Though copying 1887 files is certainly less attractive than copying 2 files.

The CF8 feature sounds like an improvement.  I'll have to play around with it more.

wow some nice info reg cf8  
I was just checking watz new in cf8 document

and found this

If you specify the scriptsrc attribute in the cfform tag and are using Flash forms, you
must include the CF_RunActiveContent.js file in the directory you specified in the
scriptsrc attribute. You can copy this file from wwwroot/CFIDE/scripts/
CF_RunActiveContent.js.".
You only need it if:
" You override the default
" You are using Flash
SOLUTION
Avatar of Scott Bennett
Scott Bennett
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Nigel-SA
Nigel-SA

ASKER

Wow you are guys are amazing - thanks
Yes it now works, removed cfide directory added  www.yoursite.com/myscripts/cfform.js with
<cfform
   scriptSrc="/myscripts/cfform.js">
...</cfform>
 One problem it works fine on the web - that's good, but now development on local drive now gives same error web had - no prompt concerning unchecked boxes.  Any suggestion to fix? if not I can live with it, thanks again
Did you make the same change to development on the local drive?

>  removed cfide directory ...
>  <cfform
>   scriptSrc="/myscripts/cfform.js">
>...</cfform>

To clarify, its not _required_ that you remove the CFIDE directory.  You could simply copy the /cfide/scripts directory into www.yoursite.com/cfide/scripts/.  Then you could use cfform without having to specify the  "scriptSrc" every time you use cfform.

   <cfform>
   ... form fields ...
   </cfform>

If for some reason you prefer to keep your scripts in the "/myscripts" directory instead,  you can change the default location in the ColdFusion 8 Administrator as SBennett mentioned.   (Assuming you have access to it) Changing the default location should also allow you to use cfform without specifying the "scriptSrc"

 ColdFusion Administrator > Server Settings > Settings page, Default CFFORM ScriptSrc Directory field.