Well to test my code I created a .cfm page
and put this code in a table...

        <td id="snow"><noscript><cfoutput>flakes</cfoutput></noscript></td>

With JS disabled or with the <noscript> tags removed,
"flakes" was shown on the screen.

When I enabled JS and left the <noscript> tag in,
"flakes" again was shown on the screen.

Rick


-----Original Message-----
From: Ian Skinner [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, April 17, 2007 2:53 PM
To: CF-Talk
Subject: RE: Client-side validation or Server-side Validation?

"
What's the method to this madness?

Do I set up some checking to see if JS is turned on
and then execute certain code accordingly?

Do I put alternate code (CF code that displays error
messages) inside <noscript> tags to only run it if
JS is disabled?
"

There may be some confusion here.  When thinking about this, it is very
important to keep in mind that CF runs on the server and JS runs on the
client AND NEVER THE TWO SHALL MIX!

This can get muddled in one's mind when thinking about dynamic JS code
generation and|or AJAX.  But even here, the CF code runs on the server
ONLY and the JS code runs on the client ONLY.

So the short answer to your last question is NO.  Putting CF code inside
<noscript> tags would never work.  The server has no idea if JS is
enables and the client would have no idea what to do with the CF code.

For me the highest level of looking at this is first build your
application with NO JS.  Just use old fashioned server/client
request/response patterns to handle the validation.  This is the fall
back code for when JS is disabled.  A user fills out the form, it is
submitted to the server, the server does the validations, if problems
our found they are displayed to the user and the user is allowed to fix
them and resubmit the form.

Then JS enhances can be added.  These can short circuit the server/clent
request/response cycle.  Either validates the data in the client or
makes AJAX request to the server for more complex validations with
hidden requests.  Then either report the errors and allow correction or
allow the form to be submitted to the server where the validations are
repeated.  Yes repeated because your server can NOT rely on the user
validations happened.

What I am suggesting is that it's not a big stretch to create a
framework/library/system that uses one set of rules to run both the
server side validation and be used to create the JS code that will run
the client side validation.  Just make sure that the application works
correctly without this code, then if it is disabled it just falls back
to the client server round trips.  The cfinput/cffrom functionality in
CF exactly this already, but if one wants something more universal then
one will need to expand on this foundation.




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:275626
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