An interesting approach, Joe.

I'm using CF 4.5 still if that matters, and haven't used <CFINPUT>
in a couple of years.

Does the "message" part of the CFINPUT tag
appear inside the form field? (I guess it would...)

Then if there were an error, the "formErrorFields" error message
would then appear below the field again?  (As you have
it coded, right?

The only problem I see with that approach is that I display
a user's original entry back into the fields of the form, so they
can see what they may have done wrong...

This is how I code all my <INPUT>'s at this point...

<CFIF IsDefined("Form.Submit")>

     <INPUT Name="FirstName" Type="Text"
                  Value="<CFOUTPUT>#Form.FirstName#</CFOUTPUT>"
                  Size="30" MaxLength="30" Class="TextInput01">

<CFELSE>

     <INPUT Name="FirstName" Type="Text" Value=""
                 Size="30" MaxLength="30" Class="TextInput01">

</CFIF>

But, I guess I could still make use of a structure instead of an array,
and just use it the same way I'm currently using the array to display
messages...
Using a structure instead of an array would make the error messages easier
to keep up with since they incorporate the name of the formfield...A form
with
38 entry fields could get a little confusing...ErrorMessage[32][1]
(Hmmm...now
which field was that, anyway...)  :o)

Thanks for the tip!  Sounds good!

Rick

  -----Original Message-----
  From: Joe Rinehart [mailto:[EMAIL PROTECTED]
  Sent: Wednesday, June 23, 2004 8:08 AM
  To: CF-Talk
  Subject: Re: Is there a way to have all CFCatch messages display at once?

  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