Rick,

Instead of using a two-dimensional array, why not just use a structure?

At the beginning of your page, you could do this:

<cfset formErrorFields = structNew()>

Then, if a given field (say, firstname was blank) had something wrong
with it, do:

<cfif not len(trim(form.firstname))>
  <cfset formErrorFields.firstname = "Please enter a first name.">
</cfif>

Then, in your form:

<cfinput type="text" name="firstname" required="true" message="Please
enter a first name"><br>
<cfif structKeyExists(formErrorFields, firstname)>
  <cfoutput>#formErrorfFields.firstname#</cfoutput>
</cfif>

Granted, this limits you to only being able to have one thing wrong
with each field at a time, but there's no reason each element couldn't
be an array containing multiple error messages per field.

-Joe

----- Original Message -----
From: Rick Faircloth <[EMAIL PROTECTED]>
Date: Wed, 23 Jun 2004 08:07:25 -0400
Subject: RE: Is there a way to have all CFCatch messages display at once?
To: CF-Talk <[EMAIL PROTECTED]>

I've worked out a way using a two dimensional array

that contains the error message in the first dimension and set the

second dimension in the row to "Yes" if there is an error found.

Formfield 1 message is ErrorMessage[1][1] and ErrorMessage[1][2] is set to

"Yes" or "No".

(No by default)

Formfield 2 message is ErrorMessage[2][1], etc...

None of this is dynamic, just hard coded.

I just validate each form field and if there is a problem, set

ErrorMessage[1][1]

to hold whatever message is appropriate for the field and ErrorMessage[1][2]

to "Yes".

Then, there is a row just above each form field and its title which will

display

it's contents, ErrorMessage[1][1], etc., if ErrorMessage[1][2] has been set

to "Yes."

Now, all problems can be addressed at once, instead of one at a time...much

better!

For long forms, and as a standard of practice for all forms, I'll trigger a

message at the

top of the form which states that there are errors in the form input, and to

please check

your entries and correct as necessary.

Works great so far!

And Dick...even colorblind folks should be able to tell when a light-colored

background field

with dark text is changed to a dark-colored background with light

text...right?

Rick



  -----Original Message-----

  From: Dick Applebaum [mailto:[EMAIL PROTECTED]

  Sent: Wednesday, June 23, 2004 12:56 AM

  To: CF-Talk

  Subject: Re: Is there a way to have all CFCatch messages display at once?

  On Jun 22, 2004, at 5:55 PM, Adrocknaphobia wrote:

  > Although rather than blast a user with all

  >  those errors, why not do something more subtle like highlight the

  >  invalid form fields with another color.

  >

  >

  I think you want to do both -- a list of errors and highlighted

  fields-- maybe highlight by default and a popup, on demand, that lists

  all the errors ( especially useful if the user has to scroll the

  screen)

  FWIW, there are a lot of color-blind users who surf the web-- at least

  that's what I have been told!

  HTH

  Dick

  "In times like these, it helps to recall that

  there have always been times like these."

  - Paul Harvey -________________________________
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to