Is there a way to use a wildcard to check and see if a certain structure
say FormErrors contains any elements as opposed to having to check
for specific structure element contents.
In other words, can I code <CFIF StructKeyExists(FormErrors.*), where * is a
wildcard,
instead of having to check for each item, such as:
<CFIF StructKeyExists(FormErrors.FirstName)
or StructKeyExists(FormErrors.LastName)
or etc...>
I want to be able to send a general alert to a form user that there are form
errors to be check below interspersed in the form if any errors exists at
all,
without having CFIF through each one...
???
Rick
-----Original Message-----
From: Rick Faircloth [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 23, 2004 9:18 AM
To: CF-Talk
Subject: RE: Is there a way to have all CFCatch messages display at once?
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]
- Is there a way to have all CFCatch messages display at onc... Rick Faircloth
- Re: Is there a way to have all CFCatch messages displ... Adrocknaphobia
- RE: Is there a way to have all CFCatch messages d... Rick Faircloth
- Re: Is there a way to have all CFCatch messag... Stan Winchester
- Re: Is there a way to have all CFCatch messages d... Dick Applebaum
- RE: Is there a way to have all CFCatch messag... Rick Faircloth
- Re: Is there a way to have all CFCatch me... Joe Rinehart
- RE: Is there a way to have all CFCat... Rick Faircloth
- Re: Is there a way to have all C... Rick Faircloth
- Re: Is there a way to have a... Joe Rinehart
- RE: Is there a way to have a... Rick Faircloth
- RE: Is there a way to have all CFCatch messages displ... Matthew Walker
- RE: Is there a way to have all CFCatch messages d... Rick Faircloth
- RE: Is there a way to have all CFCatch messages displ... Dave Watts
- RE: Is there a way to have all CFCatch messages d... Rick Faircloth