This may not be the answer you are looking for, but I had a similar code 
seperation
problem this week.



I needed to calculate some numbers and display them
BEFORE they were saved to the database. I didn't want to write the display
calculations in javascript and the database calculations in coldfusion. I
wrote cfc methods to do the calculation, and them used those methods for both.

I used some XMLHTTPRequest stuff (Ajax) to call a coldfusion script that
invoked the calculation functions, and then returned the result to the browser.

When the data was saved, I again called the calculation functions, and stored
the results.



It may sound like alot of work, but I only wanted the calculations
in one place to prevent the two sets of code from getting out of sync.



It wouldn't be too difficult to put all your form validation into a function,
and then pass the form contents to the server via a similar method, displaying
the validation results before they ever submit the form.



This may not be
what you were thinking of at all...



-Sam Curren





--- [email protected]
wrote:

Hi guys,

> 

> This may be a little of topic but possibly not. With
regards to form 

> validation, client side validation is helpful but can
be side-stepped as can 

> the use of hidden fields, so logically this makes
server side validation a 

> neccessity. Consequently my code ends up riddled
with validation logic; is 

> it the right type, does it fit in a range, does
it match a pattern etc. Is 

> there a design pattern I could use that would
make doing this sort of thing 

> cleaner or possibly a server-side validation
library / cfc available to help 

> with this?

> 

> Cheers, Pete (aka lad4bear)

> 

> 

> 

> 

> ----------------------------------------------------------

> You are subscribed to cfcdev. To unsubscribe, send an email to 
> [email protected]
with the words 'unsubscribe cfcdev' as the subject of the email.

> 

> CFCDev
is run by CFCZone (www.cfczone.org) and supported by CFXHosting 
(www.cfxhosting.com).

> 

> CFCDev is supported by New Atlanta, makers of BlueDragon

> http://www.newatlanta.com/products/bluedragon/index.cfm

> 

> An archive of the CFCDev list is available at 
> www.mail-archive.com/[email protected]

> 

> 

> 


----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to 
[email protected] with the words 'unsubscribe cfcdev' as the subject of the 
email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting 
(www.cfxhosting.com).

CFCDev is supported by New Atlanta, makers of BlueDragon
http://www.newatlanta.com/products/bluedragon/index.cfm

An archive of the CFCDev list is available at 
www.mail-archive.com/[email protected]


Reply via email to