I'm pretty sure I've found a bug in MX 7 in the way it generated CFFORM javascript validation. After upgrading from 6.1 all our CFFORM validation stopped working (creditcard, email, SS Numbers). What I've found is that on 6.1 if you had your own JavaScript function defined in the OnSubmit="checkit()" attribute, ColdFusion replaced your functin with its own,... OnSubmit="return _CF_checkCFForm_1(this)", .... and slipped your own function at the end of its own script.
Here is how it handled it on the old server with MX6.1....
Now, with MX7 installed, ColdFusion leaves the "OnSubmit" as it is and never puts in a function to call the validation scripts.
Is there a patch to fix this problem?
Here is how it handled it on the old server with MX6.1....
Code:
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
function _CF_checkCFForm_1(_CF_this)
{
if (!_CF_checkcreditcard(_CF_this.CCNum.value))
{
if (!_CF_onError(_CF_this, _CF_this.CCNum, _CF_this.CCNum.value, "Error in CCNum text."))
{
return false;
}
}
return checkit()
return true;
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<div id="jsform" style="display: none">
<FORM NAME="CFForm_1" ACTION="processreg.cfm" METHOD="POST" onSubmit="return _CF_checkCFForm_1(this)">
Now, with MX7 installed, ColdFusion leaves the "OnSubmit" as it is and never puts in a function to call the validation scripts.
Code:
<script type="text/javascript">
<!--
function _CF_checkCFForm_1(_CF_this)
{
//reset on submit
_CF_error_exists = false;
_CF_error_messages = new Array();
_CF_error_fields = new Object();
_CF_FirstErrorField = null;
//form element CCNum 'CREDITCARD' validation checks
if (!_CF_checkcreditcard(_CF_this['CCNum'].value, false))
{
_CF_onError(_CF_this, "CCNum", _CF_this['CCNum'].value, "Error in CCNum text.");
_CF_error_exists = true;
}
//display error messages and return success
if( _CF_error_exists )
{
if( _CF_error_messages.length > 0 )
{
// show alert() message
_CF_onErrorAlert(_CF_error_messages);
// set focus to first form error, if the field supports js focus().
if( _CF_this[_CF_FirstErrorField].type == "text" )
{ _CF_this[_CF_FirstErrorField].focus(); }
}
return false;
}else {
return true;
}
}
//-->
</script>
</HEAD>
<BODY>
<div id="jsform" style="display: none">
<form name="CFForm_1" action="processreg.cfm" method="post" onsubmit="return checkit(this)">