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



-----Original Message-----
From: Ben Nadel [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 15, 2007 3:34 PM
To: CF-Talk
Subject: RE: Need some help with this Regex...

 For starters, you probably want to remove the Len() inside of:

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

To:

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

Plus, the NOT IsNumeric() will ALWAYS be true since you are stripping
out all numbers. IsNumeric() will never be true... Somewhere, your logic
is screwey... What are you trying to do (in english)?


.......................
Ben Nadel
Certified Advanced ColdFusion MX7 Developer www.bennadel.com
 




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create robust enterprise, web RIAs.
Upgrade & integrate Adobe Coldfusion MX7 with Flex 2
http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP

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

Reply via email to