Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CFINPUT VALIDATION IN ColdFusion 8 doesn't work

Status
Not open for further replies.

olchik

Programmer
Jan 6, 2006
93
US
Hello,

We just got to the point when we need to upgrade our CF5 to CF8. When I tested my forms, it appears validation dones't work on any of them. I mean simple cfinput validation...here is an example of simplest code...

<script language="JavaScript1.2"><!--

function validate(f) {

if ( f.country.value == "" )
{
alert('Please enter Country');
f.country.focus();
return false;
}

if ( f.country.value == "USA" || f.country.value == "Canada" )
{
if ( f.state.value == "" )
{
alert('Please enter State');
f.state.focus();
return false;
}
}
if( ! (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test
(f.email.value)))
{

alert("Please enter valid Email address!")
return false;
}



return true;

}
//-->
</script>
</head>

<body bgcolor="#FFFFFF" text="#000000" link="#000099" vlink="#666666" alink="#6666FF">
<table width="760" border="0" cellspacing="5" cellpadding="2" align="center">


<tr>
<td>&nbsp; </td>
</tr>
<tr>
<td> All fields with * are required. <cfform method="post" action="SIGNUP.cfm" name="FORM" onSubmit="return validate(_CF_this)">
<input type="hidden" name="id"> <input type="hidden" name="entry_date">
&nbsp; <table width="100%" border="0" cellspacing="5" cellpadding="2">
<tr>
<td bgcolor="F7F7F7" width="35%">First Name: <font color="#ff0000">*</font></td>
<td width="69%"> <cfinput type="text" name="fname" size="30" required="Yes" message="Please enter your First Name!">
</td>
</tr>
<tr>
<td bgcolor="F7F7F7" width="35%">Last Name: <font color="#ff0000">*</font></td>
<td width="69%"> <cfinput type="text" name="lname" size="30" required="Yes" message="Please enter your Last Name!">
</td>
</tr>
<tr>
<td bgcolor="F7F7F7" width="35%">Company:<font color="#ff0000">*</font></td>
<td width="69%"> <cfinput type="text" name="company" size="30" required="Yes" message="Please enter your Company/Organization.">
</td>
</tr>
<tr>
<td bgcolor="F7F7F7" width="35%">Address Line 1:<font color="#ff0000">*</font></td>
<td width="69%"> <cfinput type="text" name="add1" size="40" required="Yes" message="Please enter your Address!">
</td>
</tr>
<tr>
<td bgcolor="F7F7F7" width="35%">Address Line 2:</td>
<td width="69%"> <input type="text" name="add2" size="40"> </td>
</tr>
<tr>
<td bgcolor="F7F7F7" width="35%">City:<font color="#ff0000">*</font></td>
<td width="69%"> <cfinput type="text" name="city" size="30" required="Yes" message="Please enter your City!">
</td>
</tr>
<tr>
<td bgcolor="F7F7F7" width="35%">State:<br><font size="1">(Required for United States & Canada Only)</font></td>
<td width="69%"> <cf_dynamic_select type="state" field_name="state"> </td>
</tr>
<tr>
<td bgcolor="F7F7F7" width="35%">Zip:</td>
<td width="69%"> <cfinput type="text" name="zip" size="15" required="Yes" message="Please enter your zip code"> </td>
</tr>
<tr>
<td bgcolor="F7F7F7" width="35%">Country:<font color="#ff0000">*</font></td>
<td width="69%"> <cf_dynamic_select type="country" field_name="country">
</td>
</tr>
<tr>
<td bgcolor="F7F7F7" width="35%">Phone:<font color="#ff0000">*</font></td>
<td width="69%"> <cfinput type="text" name="phone" size="20" required="Yes" message="Please enter your phone number">
</td>
</tr>
<tr>
<td bgcolor="F7F7F7" width="35%">Email:<font color="#ff0000">*</font></td>
<td width="69%"> <cfinput type="text" name="email" size="30" required="Yes" message="Please enter your email address!">
</td>
</tr>
<tr>
<td colspan="2"> <input type="submit" name="Submit" value="Submit">
<input type="reset" name="Submit2" value="Reset"> </td>
</tr>
</table>

</table>
</cfform>
..........

Does anyone has any idea why it doesn't work and how can I fix this problem????

Thank you!
 
Usually it means there is a problem with the /CFIDE mapping. That is where all the cfform validation files live. If it is not accessible, none of the cfform stuff will work.

Try and load one of the files in your browser. If you get a 404 error, that is your problem.

----------------------------------
 
Hi,

thank you for your response. I have tried to open and it did give me
"The page cannot be found
The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.

Please try the following:

* Make sure that the Web site address displayed in the address bar of your browser is spelled and formatted correctly.
* If you reached this page by clicking a link, contact the Web site administrator to alert them that the link is incorrectly formatted.
* Click the Back button to try another link.

HTTP Error 404 - File or directory not found.
Internet Information Services (IIS)


Do you know what should I do to fix it?

Thank you!
 
I don't know how to do that. Everything was set up for me by IT.:-(
 
Hi again,

I have asked IT and they told me I have used wrong URL.

It didn't give me 404 error

It gave me something like...

/*ADOBE SYSTEMS INCORPORATED
Copyright 2007 Adobe Systems Incorporated
All Rights Reserved.

NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the
terms of the Adobe license agreement accompanying it. If you have received this file from a
source other than Adobe, then your use, modification, or distribution of it requires the prior
written permission of Adobe.*/
var _CF_error_messages=new Array();
var _CF_error_fields=new Object();
var _CF_FirstErrorField=null;
var _CF_submit_status=new Array();
_CF_signalLoad=function(){
_CF_loaded=1;
};
_CF_onError=function(_1,_2,_3,_4){
if(_CF_error_fields[_2]==null){
if(_CF_FirstErrorField==null){
_CF_FirstErrorField=_2;
}
_CF_error_exists=true;
_CF_error_fields[_2]=_4;
_CF_error_messages[_CF_error_messages.length]=_4;
}
};
_CF_onErrorAlert=function(_5){
var _6="";
for(var i=0;i<_5.length;i++){
_6+=_5+"\n";
}
alert(_6);
return false;
};
updateHiddenValue=function(_8,_9,_a){
if(_9==null||_9==""){
_9=0;
}
if(document.forms[_9]==null||document.forms[_9][_a]==null){
return;
}
document.forms[_9][_a].value=_8;
};
_CF_hasValue=function(_b,_c,_d){
if(_c=="TEXT"||_c=="FILE"||_c=="PASSWORD"||_c=="CFTEXTAREA"||_c=="TEXTAREA"||_c=="CFTEXTINPUT"||_c=="DATEFIELD"){
if(_b.value.length==0){
return false;
}else{
if(_d){
str=_b.value.replace(/^\s+/,"").replace(/\s+$/,"");
if(str.length==0){
return false;
}
}
}
return true;
}else{
if(_c=="SELECT"){
for(i=0;i<_b.length;i++){
if(_b.options.selected){
return true;
}
}
return false;
}else{
if(_c=="SINGLE_VALUE_RADIO"||_c=="SINGLE_VALUE_CHECKBOX"){
if(_b.checked){
return true;
}else{
return false;
}
}else{
if(_c=="RADIO"||_c=="CHECKBOX"){
if(_b.length==undefined&&_b.checked){
return true;
}else{
for(i=0;i<_b.length;i++){
if(_b.checked){
return true;
}
}
}
return false;
}else{
if(_c=="CFTREE"){
if(_b["value"].length>0){
return true;
}else{
return false;
}
}else{
if(_c=="RICHTEXT"){
var _e=FCKeditorAPI.GetInstance(_b.id);
var _f=_e.GetXHTML();
if(_f.length==0){
return false;
}else{
if(_d){
str=_f.replace(/^\s+/,"").replace(/\s+$/,"");
if(str.length==0){
return false;
}
}
return true;
}
}else{
return true;
}
}
}
}
}
}
};
_CF_checkdate=function(_10,_11){
_10=_10.replace(/^\s+/,"").replace(/\s+$/,"");
_10=_10=_10.replace(/{d \'/,"").replace(/'}/,"");
if(_11){
if(_10.length==0){
return false;
}
}else{
if(_10.length==0){
return true;
}
}
if(_10.length==0){
return true;
}
isplit=_10.indexOf("/");
splitchr="/";
if(isplit==-1){
isplit=_10.indexOf(".");
splitchr=".";
}
if(isplit==-1){
isplit=_10.indexOf("-");
splitchr="-";
}
if(isplit==-1||isplit==_10.length){
return false;
}
var _12=_10.substring(0,isplit);
if(_12.length==4){
sYear=_10.substring(0,isplit);
isplit=_10.indexOf(splitchr,isplit+1);
if(isplit==-1||(isplit+1)==_10.length){
return false;
}
sMonth=_10.substring((sYear.length+1),isplit);
sDay=_10.substring(isplit+1);
}else{
sMonth=_10.substring(0,isplit);
isplit=_10.indexOf(splitchr,isplit+1);
if(isplit==-1||(isplit+1)==_10.length){
return false;
}
.......

I didn't copy everything, because it's too long
Do you have idea if that's what should be displayed?
Thank you!
 
Oh...I just tried my page with staging.asmeconferences.org instead of IP address and it works! Before IT upgraded development server to CF8, I have used IP address and it worked fine. Now, after upgrade, I just have to use name and not IP. Thank you very much for helping me!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top