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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MX 7 CFFORM validation bug

Status
Not open for further replies.

Smapty

Programmer
Mar 12, 2005
55
US
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....
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)">
Is there a patch to fix this problem?
 
i think it links to a .js somewhere. some times the .js isn't where ist's supposed to be and causes errors. try a search in this forum, it's been talked about before.

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
But the script does work without a user-defined "OnSubmit" function. So ColdFusion can find the .js files.
 
after i tested that link didn't go where i wanted it to. go to the cffile area and read the comments.

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
Aaaghh!!


The "work around" is not working.
Code:
OnSubmit="return _CF_checkCFForm_1(this), checkit(this)">
That will run both the scripts, but now if the first returns a false... the second can still overide the first and submit the form anyways.

Is there any way to call those two scripts so that the second will not run unless the first is passed... or alternatively that both must pass for the result to be "true"??
 
add _CF_checkCFForm_1(this) to the bottom of your existing function.

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
actually...
further down the comments (I didn't read them all because i'm not the one with the issue, but you are and should have read them all...)

livedocs said:
doxx said on May 10, 2005 at 4:36 AM :
Responding to the 2/18/05 comment from halL :

If your javascript function return a boolean value (true or false) your onSubmit attribute look like following statement:
...
<cfform onSubmit="return ( myfunction() && _CF_checkMyCFForm(this) )">

because this attribute should return only one value...
...

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
That works.


btw...

Will there be a patch to fix this bug?
 
My coldfusion 8 ball says "Outlook Good"

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top