We help IT Professionals succeed at work.

Coldfusion client side FORM validation not working

For the life of me I can't figure out why my CF client side form validation isn't working.  With the attached script, no error messages pop up if the form is submitted without data.  What am I doing wrong???
<cfform action="test.cfm">
 
First Name: 
<cfinput name="firstname" type="text" maxlength="70" required="yes" message="Please Enter your First Name" validateAt="onSubmit"/><br />
 
Last Name:
<cfinput name="lastname" type="text" maxlength="70" required="yes" message="Please Enter your Last Name" validateAt="onSubmit"/><br />
 
<cfinput type="submit" name="Submit" value="Submit" />
 
</cfform>

Open in new window

Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2015
Commented:
A common cause is that the cfform.js file cannot be found in the expected location.  CF uses javascript files to perform validation.  If the files do not exist in the expected location

http://www.yoursite.com/CFIDE/scripts/cfform.js

.. the validation will not work.  Try the above url. Replace www.yoursite.com with your root website address.  If you get an HTTP 404 error (file not found) that is your problem.

Per an adobe technote there are (3) ways to solve this problem:
http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_18653&sliceId=2

1) 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>

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

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

Author

Commented:
I tried locating the cfform.js file like you specified (http://www.yoursite.com/CFIDE/scripts/cfform.js) - with my URL instead - and I did get the 404 error.

But, to complicate things, I just noticed that the client side validation DOES work in firefox, but not in IE7.  Seems that if firefox is finding the .js IE7 would to.  What do you think?
CERTIFIED EXPERT
Most Valuable Expert 2015

Commented:
I don't see how it could work at all the file does not exist.  Check the url I typed, make sure there are no typos.  

CERTIFIED EXPERT
Most Valuable Expert 2015

Commented:
> at all the file does not exist.

... at all IF the file does not exist.
CERTIFIED EXPERT
Most Valuable Expert 2015

Commented:
I tested the code and it works for me with IE 6 and firefox.  That suggests to me either a problem with missing files or a problem with IE7.  I lean towards missing files simply because that is most common problem.  But I suppose it could be a problem with IE 7.

Author

Commented:
Well, I created a virtual directory to CFIDE as you specified above and it solved the problem in IE7.  Problem solved, but it's still strange to me the FF worked without the virtual directory.  I guess I'll just be content knowing that it works now.

Excellent help, thanks!!!

Explore More ContentExplore courses, solutions, and other research materials related to this topic.