For some reason, code after the HTML Horizontal Line Break was omitted.
Here it is again:

<CFPARAM name="attributes.fieldName" type="string" default="[not provided]">
<CFPARAM name="attributes.fieldType" type="string" default="string">
<CFPARAM name="attributes.fieldValue" type="string" default="">
<CFPARAM name="attributes.min" type="numeric" default="1">
<CFPARAM name="attributes.max" type="numeric" default="1">
<CFPARAM name="attributes.required" type="boolean" default="No">
<CFPARAM name="attributes.equalValue" type="string" default="">
<CFPARAM name="attributes.equalFieldName" type="string" default="[not
provided]">
<CFPARAM name="attributes.ReturnVariable" type="variableName"
default="errorMessage">

<CFSET errorMessage = "">

<CFIF (attributes.required eq "Yes") and (len(attributes.fieldValue) eq 0)>
        <CFSET errorMessage = " #attributes.fieldName# is required.">
<CFELSEIF (attributes.required eq "No") and (len(attributes.fieldValue) eq
0)>
        <!--- Trap to make sure we don't do a false error --->
<CFELSE>
        <CFSWITCH expression="#attributes.fieldType#">
                <CFCASE value="string">
                        <CFIF len(attributes.fieldValue) lt attributes.min>
                                <CFSET errorMessage = " #attributes.fieldName# is less 
than the minimum
#attributes.min# characters.">
                        <CFELSEIF len(attributes.fieldValue) gt attributes.max>
                                <CFSET errorMessage = " #attributes.fieldName# is more 
than the maximum
#attributes.max# characters.">
                        </CFIF>
                </CFCASE>
                <CFCASE value="match">
                        <CFIF attributes.fieldValue neq attributes.equalValue>
                                <CFSET errorMessage = " #attributes.fieldName# does 
not match
#attributes.equalFieldName#.">
                        </CFIF>
                </CFCASE>
                <CFCASE value="integer">
                        <CFIF NOT isNumeric(attributes.fieldValue)>
                                <CFSET errorMessage = " #attributes.fieldName# is not 
a number.">
                        <CFELSEIF Val(attributes.fieldValue) lt Val(attributes.min)>
                                <CFSET errorMessage = " #attributes.fieldName# is less 
than minimum
#attributes.min#.">
                        <CFELSEIF Val(attributes.fieldValue) gt Val(attributes.max)>
                                <CFSET errorMessage = " #attributes.fieldName# is more 
than maximum
#attributes.max#.">
                        <CFELSEIF Val(attributes.fieldValue) neq 
Int(Val(attributes.fieldValue))>
                                <CFSET errorMessage = " #attributes.fieldName# is not 
an integer.">
                        </CFIF>
                </CFCASE>
                <CFCASE value="numeric">
                        <CFIF NOT isNumeric(attributes.fieldValue)>
                                <CFSET errorMessage = " #attributes.fieldName# is not 
a number.">
                        <CFELSEIF Val(attributes.fieldValue) lt Val(attributes.min)>
                                <CFSET errorMessage = " #attributes.fieldName# is less 
than the minimum
#attributes.min#.">
                        <CFELSEIF Val(attributes.fieldValue) gt Val(attributes.max)>
                                <CFSET errorMessage = " #attributes.fieldName# is more 
than the maximum
#attributes.max#.">
                        </CFIF>
                </CFCASE>
                <CFCASE value="password">
                        <CFIF len(attributes.fieldValue) lt 6>
                                <CFSET errorMessage = " #attributes.fieldName# cannot 
be less than 6
characters.">
                        <CFELSEIF len(attributes.fieldValue) gt 50>
                                <CFSET errorMessage = " #attributes.fieldName# cannot 
be more than 50
characters.">
                        <CFELSEIF REFindNoCase("[[:alpha:]]", attributes.fieldValue) 
lt 1>
                                <CFSET errorMessage = " #attributes.fieldName# must 
contain at least one
alpha character.">
                        <CFELSEIF (REFindNoCase("[[:digit:]]", attributes.fieldValue) 
lt 1) and
                                                (REFindNoCase("[[:punct:]]", 
attributes.fieldvalue) lt 1)>
                                <CFSET errorMessage = " #attributes.fieldName# must 
contain at least one
numeric or punctuation character.">
                        </CFIF>
                </CFCASE>
                <CFCASE value="email">
                        <cfset structEmail =
REFindNoCase("([A-Z0-9-]{1,}\.)*([A-Z0-9-]{1,})(@)(([A-Z0-9-]{1,})(\.))+([A-
Z]{2,8})", attributes.fieldValue, 1, "TRUE") >
                        <CFIF ((len(attributes.fieldValue) gt 0) and 
((structEmail.len[1] lt
len(attributes.fieldValue)) or (structEmail.pos[1] gt 1))) >
                                <CFSET errorMessage = " #attributes.fieldName# is not 
a valid email
address.">
                        </CFIF>
                </CFCASE>
                <CFCASE value="website">
                        <cfset structWebsite = 
REFindNoCase("(([A-Z0-9-]{1,})\.)+([A-Z]{2,8})",
attributes.fieldValue, 1, "TRUE") >
                        <CFIF ((len(attributes.fieldValue) gt 0) and 
((structWebsite.len[1] lt
len(attributes.fieldValue)) or (structWebsite.pos[1] gt 1))) >
                                <CFSET errorMessage = " #attributes.fieldName# is not 
a valid website
address, example www.greatalbum.net.">
                        </CFIF>
                </CFCASE>
        </CFSWITCH>
</CFIF>

<CFSet "Caller.#attributes.ReturnVariable#" = errorMessage>

-----Original Message-----
From: Erik Britt-Webb [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, November 26, 2002 2:12 AM
To: CF-Talk
Subject: Form Field validation tag -- need help (EBW)


I've developed a form field validation tag that seems to work reasonably
well, but I'm thinking it would work even better as a UDF.  Does anyone
agree or disagree with that conclusion?  I'm attaching the code from the
custom tag below because I don't really know how to structure the CFScript
to accomplish the same goal as CFML.  If someone could help me get started
with the CFScript, I would greatly appreciate it.  Comments on the overall
approach are also welcome.  Thanks - Erik


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

Reply via email to