We were talking about this on the UK CF Dev List the other day. Cleaning up input numbers to make them into numbers rather than strings, that is....
After a bit pedantism (is that a real word?) over the neatest and tidiest regex, this is what finally spat out at the bottom.... <cfset MyNumber = ReReplace(MyNumberAsAString, '[^(-|.|0-9)]', '', 'ALL')> Basically, replace everything that is not (^) a hyphen, stop or in the range 0 to 9 with nothing. Of course this isn't going to stop a user entering multiple decimal places, so you'll still have to check it is a valid number, but at least it'll clear most things out of your number. Regards Stephen ----- Original Message ----- From: <"Everett>; <Al <[EMAIL PROTECTED]>> To: "CF-Talk" <[EMAIL PROTECTED]> Sent: Friday, February 14, 2003 2:18 PM Subject: RE: best way to enter currency format > On input, I would get all of the numbers to a consistent format. > > First, I would remove $ and , > > <cfset BidAmount=Replace(Form.BidAmount,"$","","ALL")> > <cfset BidAmount=Replace(Variables.BidAmount,",","","ALL")> > > Then if there was anything left besides numbers and a . I'd throw an > exception. Probably the easiest thing for that is > > <cfif NOT IsNumeric(Variables.BidAmount)> > ... error code ... > </cfif> > > If all passes, then put that value in the database. > > For output, just use DollarFormat(). > > > -----Original Message----- > > From: Dave Lyons [mailto:[EMAIL PROTECTED]] > > Sent: Friday, February 14, 2003 1:05 AM > > To: CF-Talk > > Subject: best way to enter currency format > > > > > > in this auction app i cant find a reasonable solution for the > > handling of the bids. I have been sitting here messing with a > > lot of the tags and it seems to me that they are very > > dependant on how the info was entered. With of course means > > that i need to format it going into the db and possibly coming out. > > will be using a ms access db. And yes I have tried to set the > > bid field to currency which just throws an error. > > > > And I cant format it coming out of the db unless the entries > > are in the same form going into the db. > > So is there a tag i have missed that would format it going in? > > understanding that some people might place bids in the following ways: > > (say user is bidding $1,000.00) > > $1,000.00 > > $1,000 > > $1000 > > 1,000.00 > > 1,000 > > 1000 > > > > any thoughts? > > > > dave > > <!--- doesnt know jack about cfm ---> > > > > > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| 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

