Here is a new version of the checkFieldSet UDF. Brett found a few issues in my UDF. First - I accidently left in a hard coded form name, donations. This was from the project I was working on. Secondly, I thought there was no way to get the particular error message for a field. Brett showed that you could get it simply by using #f#.errorString, where f is the field name. He also showed that if you put 'Error' in your second argument in the alert call it marks it as an Error window.

So - I took his code mod and modded it some more. Now the error message isn't an optional argument - it is the combination of all the error messages in the current field set. (By that I simply mean the page, or tab/accordion.)

So - here is the latest version. Enjoy.

<cffunction name="checkFieldSet" output="false" returnType="string">
   <cfargument name="fields" type="string" required="true" hint="Fields to search">
   <cfargument name="form" type="string" required="true" hint="Name of the form">
   <cfargument name="ascode" type="string" required="true" hint="Code to fire if all is good.">
            
   <cfset var vcode ="">
   <cfset var f ="">
               
   <cfsavecontent variable="vcode">
      var ok = true;
      var msg ="";
      <cfloop index="f" list="#arguments.fields#">
         <cfoutput>
         if(!mx.validators.Validator.isValid(this, '#arguments.form#.#f#')) { msg = msg + #f#.errorString + '\n'; ok=false; }
         </cfoutput>
      </cfloop>
   </cfsavecontent>
   <cfset vcode = vcode &"if(!ok) mx.controls.Alert.show(msg,'Error'); ">
   <cfset vcode = vcode &"if(ok) #ascode#">   
   <cfset vcode = replaceList(vcode,"#chr(10)#,#chr(13)#,#chr(9)#",",,")>
   
   <cfreturn vcode>      
</cffunction>