<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:
method="POST" name="myForm" onSubmit="return
checkFields(this)">
<cfform action="someAction.cfm"
method="POST" name="myForm" onSubmit="return
checkFields(document.myForm)">
method="POST" name="myForm" onSubmit="return
checkFields(document.myForm)">

4 responses so far ↓
1 tc // Nov 7, 2005 at 7:57 AM
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
2 Sean Corfield // Nov 7, 2005 at 8:26 AM
http://ray.camdenfamily.com/index.cfm/2005/9/20/Ask-a-Jedi-Flash-Form-Custom-Validation
3 Mikhail // Apr 11, 2008 at 6:56 AM
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
4 Sean Corfield // Apr 11, 2008 at 7:06 AM
Leave a Comment