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> </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">
<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!
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> </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">
<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!