I am working on this UDF, making an array of structures so that if there is an error on my form it will send the user back, highlight the fields that need to be filled in and display an error message. The problem I am having is that the Array is being set BEFORE the form is processed. The form is being submitted back to itself as you can see in the code below. Can anyone tell me what I am doing wrong?

<CFPARAM NAME="Form.Process" DEFAULT="FALSE">

<CFPARAM NAME="Variables.ErrorText" DEFAULT="">

<CFPARAM NAME="Variables.error" DEFAULT="">

<!--- Process Form and Set Errors If No errors occur  process form and move to location --->

                        <CFIF Form.Process>

                        <!--- Are required fields filled in --->

                                    <cffunction name="reqiredfields" returntype="array">

                                    <cfargument name="fields" default="" required="yes">

                                     <!--- validate your inputs, set Variables.ErrorText if anything failes --->

                                                             <cfif not len(form.city)  or not len(form.country)  or not len(form.mgender) or not len(form.dob1) or not len(form.title) or not len(form.message) or not len(form.yold) or not len(form.mold)>

                                                            <!--- If Error is found, create an Array of Structures --->

                                                            <Cfset emessage = ArrayNew(1)>

                                                            <Cfset emessage [1] = StructNew()>

                                                            <Cfset emessage[1].ecode = "main">

                                                            <cfset emessage[1].edisplay = "Required fields are blank">

                                                            </Cfif>

                                    <cfreturn emessage>

                                    </cffunction>

                        </cfif>

<CFIF ArrayLen(reqiredfields()) GT 0>
   <link rel=""STYLESHEET"" type=""text/css"" href=""> <title> Sign Up Form - Error</title>">

<Cfelse>
    <link rel=""STYLESHEET"" type=""text/css"" href="">
<title>Sign Up Form </title>">

</CFIF>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to