The display of form errors with JS off seems similar to what I do now.
(I've only validated with CF up until now...)

I submit the form back to itself, and at the top of the page, if
a certain form variable exists, the CF code is run to validate all
entries.

I create a struct, usually called Form_Errors to hold the error
messages and as I validate each entry, a Form_Errors message
is created, e.g. Form_Errors.Name_Error, which might be
"You must enter your name.", if no name is entered.

All fields are validated, then any error messages shown along with
any data in the fields the user entered.  If all fields pass validation,
then the user is sent to a success page.

Seems like a similar process to your ex2_process.cfm page.

I'm uncertain as to how the rest of it interacts.  Perhaps it'll become
clearer when I study it more.

Thanks for the example!

Rick

Hmmm... do you have two methods, JS and non-JS intertwined?
The part of the code below that is operable seems to depend on
whether JS is in use (the "structKeyExists(url, "ajax") etc., or 
whether JS is not in use (the part after the cfelse... cfincluding
the #form.formUrl#, which would be the ex2.3_mailing_list_validation.cfm
page, right?)

Or am I just "lost in the sauce"?

:o\





-----Original Message-----
From: Dan G. Switzer, II [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, April 17, 2007 4:18 PM
To: CF-Talk
Subject: RE: Client-side validation or Server-side Validation?

Rick,

>There's no reason to use <noscript>. Server-side errors should/will only
>occur when the client has already tried filling out the form and something
>failed and you need to display them a message.
>
>So, there's no reason to even display a message unless there was a failure
>caught by the server. Regardless of whether or not JS was enabled, you need
>to display the message to the user.

Here's an example of exactly what I'm talking about:
http://www.pengoworks.com/workshop/jquery_demo/ex2.3_mailing_list_validation
...cfm

(Watch line wrapping.)

And here's what the CF code looks like:
<div id="formContent">
  <div id="errorMessage">
    <cfif structKeyExists(variables, "stAction") and NOT stAction.success>
       <!---//
         generate the error in a label tag, this will allow clicking of the
         error to take you to the form field. this is also the syntax used
         by the jQuery Form Validation tool, so any error in the label will
         be dynamically replaced by the Form Validation tool
       //--->
       <label style="display: inline;" class="error" 
         generated="true" for="email">
         <cfoutput>#stAction.message#</cfoutput>
       </label>
     </cfif>
  </div>

  <label for="email">
    E-mail Address:
  </label>

  <input type="text" name="email" id="email" />
  <input type="submit" value="Sign Up" />
</div>

Try running the page w/JS enabled. Try just submitting the form and then
enter some data that's not an e-mail address. 

If you notice, the error messages will display w/out the URL ever
changing--this is because the validation is being done on the client-side. 

Now if you disable JS and reload the page and repeat the process, you'll
notice the URL changes. This is because the validation occurs at the server.
All I'm doing is re-displaying the page but outputting an errors the server
may have generated.

You can view the source code to view the client-side validation. About 90%
of the code for doing the client-side validation is just comments explaining
what's going on.

-Dan




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create robust enterprise, web RIAs.
Upgrade & integrate Adobe Coldfusion MX7 with Flex 2
http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:275647
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to