Also... you can see how this is working at:

http://bodaford.whitestonemedia.com/html/trial_field_validation.cfm

Rick

-----Original Message-----
From: Rick Faircloth [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 15, 2007 4:40 PM
To: CF-Talk
Subject: RE: Need some help with this Regex...

Hi, Ben... and thanks for the reply...

Ok... I figured out the problem... my Regex is correct as is,
however, a conditional statement prior to it needed to be adjusted.

Here's what's going on:

jQuery is submitting info via Ajax from a form field to the code below
for validation.  (In this case I'll use the "Years" form data)

        <CFIF Not Len(Trim(Form.Years))>
        
                <CFSET Years_Error_Message = "Please enter the number of
years.">
                
        </CFIF>
                
        <CFIF Len(Trim(REReplace(Form.Years, "[0-9]","","All")))
                  and Not IsNumeric(REReplace(Trim(Form.Years),
"[0-9]","","All"))>
                
                <CFSET Years_Error_Message = "Please enter a valid number
for years.">
                         
        </CFIF>

Now, I've change the first condition of the second CFIF to read:

<CFIF Len(Trim(REReplace(Form.Years, "[0-9]","","All")))...

That verifies that there is data besides digits, which is what I'm trying to
find out.
The next condition, after the "and", checks to make sure that the data is
not numeric
after all digits are removed... (this may be redundant now...)

Here's the final code (at this point...) for validating the "Years" field.

        <CFIF Not Len(Trim(Form.Years))>
        
                <CFSET Years_Error_Message = "Please enter the number of
years.">
                
        </CFIF>
                
        <CFIF Len(Trim(REReplace(Form.Years, "[0-9]","","All")))
                  and Not IsNumeric(REReplace(Trim(Form.Years),
"[0-9]","","All"))>
                
        <CFSET Years_Error_Message = "Please enter a valid number for
years.">
                         
        </CFIF>

Rick

..4



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Upgrade to Adobe ColdFusion MX7
The most significant release in over 10 years. Upgrade & see new features.
http://www.adobe.com/products/coldfusion?sdid=RVJR

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:272760
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to