> Well, that's the thing: I don't have a particular scenario in mind. I'm
> looking more for conceptual and
>methodological ideas, e.g., "the user has submitted the form: now what?".
Hi Joel,
I wrote myself a validation CFC to handle as wide a range of form
validations as possible.
In the form I'm submitting, I include a hidden input field that looks sorta
like this:
<input type="hidden" name="validate_config" value="
firstname^First Name^yes^string|
lastname^Last Name^yes^string|
email^Email^yes^email">
The values 1^2^3^4 equate to:
1: field name
2: display name - used if an error occurs to display to user
3: is required? - boolean
4: data type as defined by the CF isValid function
The validate method takes the validate_config string, parses it and uses
isValid(data type) on the fields to validate the form accordingly. It
doesn't handle dependencies (i.e. if field 1 is empty then field 2 must have
a value) but it will handle most basic requirements. Any errors are kicked
back in an array or a string if you like.
Once this is up and running and cached in the Application scope, in your
action page you just do something like:
<cfset errors = Application.validate.validate(form,form.validate_config)>
<cfif not arraylen(errors)>
<!--- update db or whatever --->
</cfif>
Here's the code if you want to have a look:
http://www.oakcitygraphics.com/validatecfc.txt
-- Josh
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Check out the new features and enhancements in the
latest product release - download the "What's New PDF" now
http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:286163
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4