hi Qasim,
I was doing something similar to this when your answer arrived, only I wasn't using urlencoding (though it was still working). After I broke it down to a simple test case and compared to my login form I realised I needed to pass the values back via the url.  I must admit I'm still not sure why. Oh, and one last thing -- thanks!

Regards

Mark Henderson
Web Designer
mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>

205 Main Street
PO Box 143, Gore
Southland 9700
Phone: (03) 203 9999
Fax: (03) 203 9900

-----Original Message-----
From: Qasim Rasheed [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 19, 2004 3:14 PM
To: CF-Talk
Subject: Re: form validation problems

Pass the message with cflocation too

<cfif variables.msg IS NOT "">
  <cfset variables.msg="<h1>ENTRY ERROR</h1>The following error(s)
were detected:<ul>#variables.msg#</ul>">
   <cflocation URL=""> variables.msg  )#">
</cfif>   

----- Original Message -----
From: Mark Henderson <[EMAIL PROTECTED]>
Date: Thu, 19 Aug 2004 12:43:32 +1200
Subject: form validation problems
To: CF-Talk <[EMAIL PROTECTED]>

I've recently revisited some form validation issues, and once again
it's driving me batty. Here is what I have so far...

here's the main part of the form from dsp_register.cfm
at the top I set a default value for variables.msg and form fields

<cfparam name="form.team_name" default="">
<cfparam name="form.company_name" default="">
<cfparam name="form.address_1" default="">
<cfparam name="form.email" default="">
<cfparam name="variables.msg" default="">

<cfif isdefined("client.form_variables")>
  <cfwddx action="" input="#client.form_variables#" output="formTemp">
  <cfloop index="formItem" list="#StructKeyList(formTemp)#">      
    <cfset StructInsert(form,formItem,evaluate("formTemp." &
formItem), true)>
  </cfloop>
</cfif>

  <cfif variables.msg is not "">
    <p>#variables.msg#</p>
  </cfif>

<form name="npcregister" method="post" enablecab="No"
  action=""> class="center">
  <div class="rugbyform">
    Team Name:<br />
    <input type="text" name="team_name" value="#form.team_name#"
size="34" /><br />
    Company Name:<br />
    <input type="text" name="company_name" value="#form.company_name#"
size="34" /><br />
    Address 1:<br />
    <input type="text" name="address_1" value="#form.address_1#"
size="34" /><br />
    Email:<br />
    <input type="text" name="email" size="34" /><br /><br />

    Charge my Chamber account
    <input type="radio" name="payment" value="charge chamber"
class="radio" /><br />
    I will forward payment to Box 237, Gore
    <input type="radio" name="payment" value="forward payment"
class="radio" /><br /><br />
    <input type="submit" name="submit" id="submit" value="Submit"
class="button" />
    <input type="reset" name="reset" id="reset" value="Reset" class="button" />
  </div>

</form>

it then gets sent to the XFA.submitRegister for validation (using
act_validateRegisterInfo.cfm) which is as follows:

<cfwddx action="" input="#form#"
output="client.form_variables" usetimezoneinfo="No">

  <cfif form.team_name IS "">
    <cfset variables.msg=variables.msg & "<li>You must enter your team
name</li>">
  </cfif>
  <cfif form.company_name IS "">
    <cfset variables.msg=variables.msg & "<li>You must enter your
company name</li>">
  </cfif>
  <cfif form.address_1 IS "">
    <cfset variables.msg=variables.msg & "<li>You must enter a valid
address</li>" >
  </cfif>
   
<cfif variables.msg IS NOT "">
  <cfset variables.msg="<h1>ENTRY ERROR</h1>The following error(s)
were detected:<ul>#variables.msg#</ul>">
   <cflocation URL=""> </cfif>   

Which by rights should send the user back to the form if one of the
above fields is empty, and above the form it should list the errors.
However, when a field is left empty such ss company_name, it will send
me back and it will display the values I had previously entered (using
cfwddx) that were ok...but it WONT show me the variables.msg for those
invalid entries (variables.msg is always "")

What am I doing wrong? All I want to do is output the relevant error
messages in a list when the user is returned to the form and keep
previously entered form data. Help! Or is there another more efficient
way of achieving this? I've heard of cf_reuseform but know nothing
about it.

All help greatly appreciated. TIA

Regards
Mark
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to