Viewing By Entry / Main
November 5, 2005
I've seen a couple of people trip over this so I thought I'd better blog something about the issue...

If you use cfform and have your own onSubmit handler to perform custom field validation, you probably have something that looks like this:

<cfform action="someAction.cfm"
method="POST" name="myForm" onSubmit="return
checkFields(this)"
>
If you have any auto-validation on your cfinput forms, ColdFusion MX 7.0.1 will rewrite the onSubmit to call its auto-generated validation Javascript that will in turn call your original onSubmit code. That fixes a bug in earlier versions where either your Javascript would run or the auto-generated Javascript would run, but not both. However, there is a subtle side-effect: the above code stops working.

Why is that? CFMX ends up calling checkFields(this) from inside the auto-generated Javascript and this refers to that code, not the original form. The fix is to use a named reference to the form object instead of this:

<cfform action="someAction.cfm"
method="POST" name="myForm" onSubmit="return
checkFields(document.myForm)"
>

Comments

Sean, I can't find in the CFMX 7.01 documentation how the OnSubmit and OnReset work when dealing with cfforms type=Flash. Does you example in the article work the same with Flashed based CFFORMS?

Thanks, TC


With Flash forms you can't use Javascript - you need to use ActionScript instead. See Ray Camden's "Ask a Jedi" entry on this:

http://ray.camdenfamily.com/index.cfm/2005/9/20/Ask-a-Jedi-Flash-Form-Custom-Validation


Hi Sean, Since I upgrade to CF MX7 any auto-validation on my cfinput forms stops working, On submit only my custom Javascript calls Your example working OK on CF 6.1 but auto-validation does not work on CF MX7 Please advise Thanks


@Mikhail, impossible to tell from your brief description. I suggest you post your code on cf-talk and get someone who is still using CFMX 7 to help you (I haven't had access to a local CFMX 7 installation for about 18 months).


Post Your Comments
Name:
Email Address:
Comments
*** Please note that all comments require moderation so it may be some time before your comment posts to this blog! ***
Remember My Information:
 



Hosting provided by