Ask a Jedi: Flash Form Custom Validation

A reader asks:

Ray, any easy way to do custom validation of Flash forms on submit (like making sure password and confirmPassword are the same)? And how to "inject" the appropriate message into the Flash validation pop-ups?

Part of the answer is rather simple. Flash Forms support an onSubmit call. You can then run ActionScript code to do whatever you want. Here is a simple example:

<cfsavecontent variable="verify">
if(password.text != password2.text) {'Password and Confirmation Password do not match!','Error');
   return false;
return true;

<cfform format="flash" name="test" width="400" onSubmit="#verify#">
   <cfinput type="text" name="name" required="true" message="Enter your name!" label="Name">
   <cfinput type="password" name="password" required="true" message="Enter your password!" label="Password">
   <cfinput type="password" name="password2" required="true" message="Enter your confirmation password!" label="Confirm Password">
   <cfinput type="submit" name="submit" value="Save">

In this example, when the submit button is pushed, we check to see if the password and the confirmation password match up. If not, we use an Alert box to show a message. This is not the exact same popup as the built-in Flash Forms errors, but it is close enough. (I bet the smart cookies over at know how to do that.) Obviously you would change the AS code to match the custom validation you require.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA