That's a really clever idea. I'm a FB guy so I never really been in that
situation (and I usually prefer to generate all error message not just the
first), but if that's what you're looking for, I'd say it's a perfect
solution.
Here's a different take on the same idea, except using the same template as
both the form and the validation custom tag. Obviously have to flesh it
out, but it'll let you have both your custom tag and your consolidated code
all in one.
------------------------------------------------------------------------
<cfif isDefined("thistag")>
<!--- validation --->
<cfif len(form.email) EQ 0>
<cfexit method="exittag" />
<cfelseif ... >
...
</cfif>
<cfelse>
<!--- form --->
<cfif isDefined("form.myFirstField")>
<cfmodule template="#getFileFromPath(getCurrentTemplatePath())#" />
</cfif>
<form ...>
...
</form>
</cfif>
------------------------------------------------------------------------
---
Barney Boisvert, Senior Development Engineer
AudienceCentral
[EMAIL PROTECTED]
voice : 360.756.8080 x12
fax : 360.647.5351
www.audiencecentral.com
> -----Original Message-----
> From: Jim Davis [mailto:[EMAIL PROTECTED]
> Sent: Friday, June 27, 2003 4:27 PM
> To: CF-Talk
> Subject: Smart or Stupid (CFLOOP as a GOTO)
>
>
> This may be a VERY dumb question, but I'm brain fried.
>
> Okay - so I'm working on a form and I need to validate fields for many
> things. Taking "email address" for example I need to validate that it's
> been filled in (not zero length), that it's less than 255 characters (the
> database limit), that it fits a email format and finally that the email
> address isn't already in use.
>
> What I'd like to be able to do is check through all these
> validations. The
> instant a problem is found I want to stop checking. I would then
> redisplay
> the form and so forth.
>
> In a custom tag or function I might, when an error is found
> simply "return"
> to the caller with the error information. Since this is a rather
> small set
> and is only the first of many small forms I decided (perhaps wrongly) to
> just do the validation at the top of the page.
>
> To simulate a components ability to return at any point I wrapped
> the whole
> validation block in a CFLOOP from 1 to 1 (1 iteration) - as soon
> as I hit an
> error (and set the error variable) I CFBREAK. Right after the
> loop I check
> the value of the error variable.
>
> Now that I'm looking at it I'm not sure... is this just the
> stupidest thing
> you're ever heard? Should I take the extra time and create a customized
> validation custom tag for each and every form?
>
> Jim Davis
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription:
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Your ad could be here. Monies from ads go to support these lists and provide more
resources for the community.
http://www.fusionauthority.com/ads.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4