So, basically, what you're saying (besides "upgrade!" :o),
is that it can't be done with any combination of CFIF statements...right?

I'm trying to figure out if I'm just continuing to beat a dead horse...

Rick

> -----Original Message-----
> From: S. Isaac Dealey [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, March 07, 2006 10:08 AM
> To: CF-Talk
> Subject: RE: Ok, I give...how can I do this...
> 
> 
> > CFIF Len(Trim(Form.Dollar_Amount)) and Not
> > IsNumeric(LSParseNumber(Form.Dollar_Amount))
> 
> >     - Now why didn't this work? Oh, now I remember...a junk
> >     entry like, asdflkj, can't
> >       be parsed by LSParseNumber and throws a CF error...
> 
> Oh yeah, sorry... I forgot that the behavior of LSParseNumber() is ...
> horrific...
> 
> It would be _MUCH_ better for it to return an empty string than to
> throw an error, but I digress...
> 
> <cftry>
>    <cfif len(trim(form.dollar_amount)) and
>    not isNumeric(LSParseNumber(trim(form.dollar_amount)))>
>       <cfthrow type="validation" message="not a number">
>    </cfif>
>    <cfcatch>
>       ... do some stuff with the bad number information ...
>    </cfcatch>
> </cftry>
> 
> Here's a good reason to upgrade. :) If you were using a more recent
> version of CF (specifically MX or later) you could put this try-catch
> block into a custom function so that you wouldn't have to repeat it
> for each field you wanted to validate.
> 
> Note that I trim the form value before executing LSParseNumber() -- I
> suspect that white space before or after the number may also cause an
> error on an otherwise valid number, so it's probably better to just
> trim it to be sure.
> 
> 
> > CFIF Len(Trim(Form.Dollar_Amount)) and Not
> > IsNumeric(LSParseNumber(Val(Form.Dollar_Amount)))
> 
> >     - Worked for entries like 1,000 but didn't work with junk
> >     entries, like
> > sldifjo,
> >       because I think Val created a value of 0 for the string
> 
> Yep, it does. Val() in general is probably most useful for performing
> math with query data when the column might contain a null.
> 
> 
> s. isaac dealey     434.293.6201
> new epoch : isn't it time for a change?
> 
> add features without fixtures with
> the onTap open source framework
> 
> http://www.fusiontap.com
> http://coldfusion.sys-con.com/author/4806Dealey.htm
> 
> 
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:234447
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to