RE: Ok, I give...how can I do this...
What seems to have covered all the bases in my situation is to run two error traps: Not Len(Trim(Form.Amount)) - Catches empty formfields Len(Trim(Form.Ammount)) and Not IsNumeric(REReplace(Form.Premium, "[.$,]","","All"))> - This code makes sure there is data in the field - Allows for $ , . to be entered, but stripped out. This is important because many times for dollar amounts, those characters are used and should not trigger an error for the user - Catches data entered into the field which is just a garbage entry, such as oweinfe9, does not assign it a value as using VAL would, but doesn't accept this garbage entry by stripping out all the non-numeric characters and turning the entry into $9.00, for example - It would catch the entry as incorrect, redisplay the entry in the formfield for the user to inspect and allow changes - By using this line of code, I can also redisplay the entry in DollarFormat for the user, then have the $., stripped back out by this line for processing Those two trapping statements seems to cover all the bases, but it's hard to anticipate everything someone might throw in a formfield. Rick > -Original Message- > From: Eric Roberts [mailto:[EMAIL PROTECTED] > Sent: Tuesday, March 07, 2006 11:29 PM > To: CF-Talk > Subject: RE: Ok, I give...how can I do this... > > > Numberformat(number,".99") worked for my problem. Unless you specify a > comma, numberformat will not put one in (with the exception of if > you do not > put in a mask). I didn't realize that decimalformat outputs a > string value > (that's what I get for not reading the manual hehehehe) > > Eric > > -Original Message- > From: Dawson, Michael [mailto:[EMAIL PROTECTED] > Sent: Tuesday, 07 March 2006 08:23 > To: CF-Talk > Subject: RE: Ok, I give...how can I do this... > > I would use a regular expression to remove *all* non-numeric characters. > Then, check to see if the remainder is numeric. You could do this both on > the client and the server. > > M!ke > > -Original Message----- > From: Rick Faircloth [mailto:[EMAIL PROTECTED] > Sent: Monday, March 06, 2006 7:16 PM > To: CF-Talk > Subject: RE: Ok, I give...how can I do this... > > Thanks for the tip, Josh...yet another way I'll have to validate an entry. > Maybe it's just easier to let them make an illegal entry, then > tell them how > I want them to enter the data than try to catch all the possible > violations... > > I wonder what will happen if they enter > $1,000 and I run it against > IsNumeric(Replace(Form.Dollars, ",","","all")) ? > What about that dollar sign? > > I'll have to see...thanks, Josh... > > > > ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:234598 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
RE: Ok, I give...how can I do this...
Numberformat(number,".99") worked for my problem. Unless you specify a comma, numberformat will not put one in (with the exception of if you do not put in a mask). I didn't realize that decimalformat outputs a string value (that's what I get for not reading the manual hehehehe) Eric -Original Message- From: Dawson, Michael [mailto:[EMAIL PROTECTED] Sent: Tuesday, 07 March 2006 08:23 To: CF-Talk Subject: RE: Ok, I give...how can I do this... I would use a regular expression to remove *all* non-numeric characters. Then, check to see if the remainder is numeric. You could do this both on the client and the server. M!ke -Original Message- From: Rick Faircloth [mailto:[EMAIL PROTECTED] Sent: Monday, March 06, 2006 7:16 PM To: CF-Talk Subject: RE: Ok, I give...how can I do this... Thanks for the tip, Josh...yet another way I'll have to validate an entry. Maybe it's just easier to let them make an illegal entry, then tell them how I want them to enter the data than try to catch all the possible violations... I wonder what will happen if they enter $1,000 and I run it against IsNumeric(Replace(Form.Dollars, ",","","all")) ? What about that dollar sign? I'll have to see...thanks, Josh... ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:234580 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=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
RE: Ok, I give...how can I do this...
I got it! (I think this is the first time I've ever used a Regex...sad, huh?) I couldn't use the UDF M!ke mentioned, but I did take the Regex from the code and used as follows: (This code allows an entry of a number in any format, such as, $1,000, or 1,000 to entered and not cause an error on either the processing or display side...) 4.5.2 lives! :o) Error Trapping Code: Display Code for the FormField: > -Original Message- > From: Rick Faircloth [mailto:[EMAIL PROTECTED] > Sent: Tuesday, March 07, 2006 10:56 AM > To: CF-Talk > Subject: RE: Ok, I give...how can I do this... > > > 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... > > > > > > >not isNumeric(LSParseNumber(trim(form.dollar_amount)))> > > > > > > > > ... do some stuff with the bad number information ... > > > > > > > > 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:234453 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
RE: Ok, I give...how can I do this...
> 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... Nope. Unfortunately because LSParseNumber() throws an error on any value it can't parse, no amount of CFIF is going to be a complete solution. You have to have a try-catch in it somewhere, otherwise your page is just going to display a CF error to your user if they enter some value CF doesn't understand. This is why I really wish LSParseNumber would return an empty string instead of producing an error -- because if it did, you could gracefully use just cfif statements to test for valid numbers and wouldn't need the extra try-catch statements. :::sigh::: CF's internationalization features in general seem to be rather lacking unfortunately. They're certainly a lot better with more recent versions of the server (and for most of us a bit easier to use than Java -- I can't compare to PHP or ASP), but still fairly less than ideal. Granted that throwing an error is what Java's NumberFormat objects do with unrecognizable strings also, so it's consistent with Java's behavior -- it's just not very easy/intuitive/useful/helpful behavior (much like Java at large). 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:234452 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=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
RE: Ok, I give...how can I do this...
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... > > >not isNumeric(LSParseNumber(trim(form.dollar_amount)))> > > > > ... do some stuff with the bad number information ... > > > > 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
RE: Ok, I give...how can I do this...
Oh, bummer, M!ke! That requires at least CF 5...I'm still on CF 4.5.2... Ok, everyone chime in..."Upgrade, Rick, Upgrade! Join us in the new millineum!" :o) > -Original Message- > From: Dawson, Michael [mailto:[EMAIL PROTECTED] > Sent: Tuesday, March 07, 2006 9:53 AM > To: CF-Talk > Subject: RE: Ok, I give...how can I do this... > > > CFLib to the rescue... > > http://www.cflib.org/udf.cfm?ID=433 > > M!ke > > -Original Message- > From: Rick Faircloth [mailto:[EMAIL PROTECTED] > Sent: Tuesday, March 07, 2006 8:51 AM > To: CF-Talk > Subject: RE: Ok, I give...how can I do this... > > Sounds good...since I can't write RegEx's, could you whip one up for me > without too much trouble? > > Rick > > ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:234446 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=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
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... ... do some stuff with the bad number information ... 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:234433 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=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
RE: Ok, I give...how can I do this...
CFLib to the rescue... http://www.cflib.org/udf.cfm?ID=433 M!ke -Original Message- From: Rick Faircloth [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 07, 2006 8:51 AM To: CF-Talk Subject: RE: Ok, I give...how can I do this... Sounds good...since I can't write RegEx's, could you whip one up for me without too much trouble? Rick ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:234428 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
RE: Ok, I give...how can I do this...
Sounds good...since I can't write RegEx's, could you whip one up for me without too much trouble? Rick > -Original Message- > From: Dawson, Michael [mailto:[EMAIL PROTECTED] > Sent: Tuesday, March 07, 2006 9:23 AM > To: CF-Talk > Subject: RE: Ok, I give...how can I do this... > > > I would use a regular expression to remove *all* non-numeric characters. > Then, check to see if the remainder is numeric. You could do this both > on the client and the server. > > M!ke > > -Original Message- > From: Rick Faircloth [mailto:[EMAIL PROTECTED] > Sent: Monday, March 06, 2006 7:16 PM > To: CF-Talk > Subject: RE: Ok, I give...how can I do this... > > Thanks for the tip, Josh...yet another way I'll have to validate an > entry. Maybe it's just easier to let them make an illegal entry, then > tell them how I want them to enter the data than try to catch all the > possible violations... > > I wonder what will happen if they enter > $1,000 and I run it against > IsNumeric(Replace(Form.Dollars, ",","","all")) ? > What about that dollar sign? > > I'll have to see...thanks, Josh... > > ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:234427 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
RE: Ok, I give...how can I do this...
I would use a regular expression to remove *all* non-numeric characters. Then, check to see if the remainder is numeric. You could do this both on the client and the server. M!ke -Original Message- From: Rick Faircloth [mailto:[EMAIL PROTECTED] Sent: Monday, March 06, 2006 7:16 PM To: CF-Talk Subject: RE: Ok, I give...how can I do this... Thanks for the tip, Josh...yet another way I'll have to validate an entry. Maybe it's just easier to let them make an illegal entry, then tell them how I want them to enter the data than try to catch all the possible violations... I wonder what will happen if they enter $1,000 and I run it against IsNumeric(Replace(Form.Dollars, ",","","all")) ? What about that dollar sign? I'll have to see...thanks, Josh... ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:234421 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
RE: Ok, I give...how can I do this...
I did try using LSParseNumber in my error catching, but that didn't work out completely...don't remember why at this point... I need to be able to catch an input problem and return an appropriate error message. CFIF Not Len(Trim(Form.Dollar_Amount)) - Good for catching no entry CFIF Len(Trim(Form.Dollar_Amount)) and Not IsNumeric(Form.Dollar_Amount) - Good for catching just junk entries like, sadfsdd, but also catches 1,000 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... 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 So... I need to trap no entries, entries of junk, and not trap entries with commas and strictly numeric entries (without commas) I just haven't been able to put together a sequence of traps for all entry possiblities...maybe I've been working on it too long for now... Rick > -Original Message- > From: S. Isaac Dealey [mailto:[EMAIL PROTECTED] > Sent: Tuesday, March 07, 2006 12:35 AM > To: CF-Talk > Subject: RE: Ok, I give...how can I do this... > > > Nope, comma's never been part of a number in CF... It uses US > formatted numbers (as far as I'm aware), but discluding commas. I > believe this is a pretty standard format for numbers in computing > languages... But because humans like to format their numbers we have > LSParseNumber() and LSParseCurrency() to convert user-provided values > with commas and such into machine numbers with the appropriate format > for CF to treat them as numeric values. I don't use LSParseNumber() or > LSParseCurrency() myself as I don't prefer to rely on CF's > localization features, partly because they don't allow you to override > the default locale without _setting_ the default locale using > SetLocale() so I implemented my own localization methods using Java > which accept the locale as an optional argument with a request-based > default. > > > I have to snicker at the irony of this being a *new* > > bug in CF7...I'm still using 4.5.2! :o) > > > Rick > > > >> -----Original Message- > >> From: Eric Roberts > >> [mailto:[EMAIL PROTECTED] > >> Sent: Monday, March 06, 2006 10:30 PM > >> To: CF-Talk > >> Subject: RE: Ok, I give...how can I do this... > >> > >> > >> I think it should. I have been having similar probs > >> lately with CF7 where > >> numbers that have commas in them are viewed as strings. > >> I don't ever > >> remember having this prob with previous versions...is > >> this a new > >> bug in 7? > >> > >> Eric > >> > >> -Original Message- > >> From: Rick Faircloth [mailto:[EMAIL PROTECTED] > >> Sent: Monday, 06 March 2006 17:56 > >> To: CF-Talk > >> Subject: Ok, I give...how can I do this... > >> > >> Should a field entry of "1,000" validate as a numeric? > >> > >> e.g. IsNumeric(Form.Dollars) > >> > >> (Where Form.Dollars has a value of "1,000) > >> > >> Rick > >> > >> > >> > >> > >> > >> > >> > >> > >> > > > ~~ > > > > ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:234410 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=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
RE: Ok, I give...how can I do this...
Nope, comma's never been part of a number in CF... It uses US formatted numbers (as far as I'm aware), but discluding commas. I believe this is a pretty standard format for numbers in computing languages... But because humans like to format their numbers we have LSParseNumber() and LSParseCurrency() to convert user-provided values with commas and such into machine numbers with the appropriate format for CF to treat them as numeric values. I don't use LSParseNumber() or LSParseCurrency() myself as I don't prefer to rely on CF's localization features, partly because they don't allow you to override the default locale without _setting_ the default locale using SetLocale() so I implemented my own localization methods using Java which accept the locale as an optional argument with a request-based default. > I have to snicker at the irony of this being a *new* > bug in CF7...I'm still using 4.5.2! :o) > Rick >> -Original Message- >> From: Eric Roberts >> [mailto:[EMAIL PROTECTED] >> Sent: Monday, March 06, 2006 10:30 PM >> To: CF-Talk >> Subject: RE: Ok, I give...how can I do this... >> >> >> I think it should. I have been having similar probs >> lately with CF7 where >> numbers that have commas in them are viewed as strings. >> I don't ever >> remember having this prob with previous versions...is >> this a new >> bug in 7? >> >> Eric >> >> -Original Message- >> From: Rick Faircloth [mailto:[EMAIL PROTECTED] >> Sent: Monday, 06 March 2006 17:56 >> To: CF-Talk >> Subject: Ok, I give...how can I do this... >> >> Should a field entry of "1,000" validate as a numeric? >> >> e.g. IsNumeric(Form.Dollars) >> >> (Where Form.Dollars has a value of "1,000) >> >> Rick >> >> >> >> >> >> >> >> >> > ~~ > ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:234399 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
RE: Ok, I give...how can I do this...
It's funny...I finally got around to ignoring cfform in 4.5.2 and running my own validation and using cfqueryparam, etc...now I'm surrfering because I'm not using it with CF7... For now I need to go with a REReplace to strip out anything but 0-9...could you show me how to write that? (Couldn't find that example in my dog-eared copy of CF Application Kit for 4.0 published in 1998 by somebody named "Forta"... :o) Rick > -Original Message- > From: Mike Kear [mailto:[EMAIL PROTECTED] > Sent: Monday, March 06, 2006 10:00 PM > To: CF-Talk > Subject: Re: Ok, I give...how can I do this... > > > i hate to keep on beating a dead horse, but in CFMX7, you just use instead of validate="numeric" and it takes care of it for you. They > CANT enter > anything but numbers in there. > > However since you're not using CFMX7 you can use a javascript validation > routine to disallow submitting the form unless there's only > numeric in that > field.or you can allow them to submit it and use REReplace to > strip out > all but 0-9 on the server side in your action page. > > > Cheers > Mike Kear > Windsor, NSW, Australia > Certified Advanced ColdFusion Developer > AFP Webworks > http://afpwebworks.com > ColdFusion, PHP, ASP, ASP.NET hosting from AUD$15/month > > > On 3/7/06, Rick Faircloth <[EMAIL PROTECTED]> wrote: > > > > What would be the best way to strip out > > any content a person might enter besides > > numerals, so that IsNumeric(Val(Form.Premium)) > > would work? > > > > (I think I feel a Regex coming on...anyone?) > > > > Rick > > > > > > > ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:234393 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
RE: Ok, I give...how can I do this...
I have to snicker at the irony of this being a *new* bug in CF7...I'm still using 4.5.2! :o) Rick > -Original Message- > From: Eric Roberts [mailto:[EMAIL PROTECTED] > Sent: Monday, March 06, 2006 10:30 PM > To: CF-Talk > Subject: RE: Ok, I give...how can I do this... > > > I think it should. I have been having similar probs lately with CF7 where > numbers that have commas in them are viewed as strings. I don't ever > remember having this prob with previous versions...is this a new > bug in 7? > > Eric > > -Original Message- > From: Rick Faircloth [mailto:[EMAIL PROTECTED] > Sent: Monday, 06 March 2006 17:56 > To: CF-Talk > Subject: Ok, I give...how can I do this... > > Should a field entry of "1,000" validate as a numeric? > > e.g. IsNumeric(Form.Dollars) > > (Where Form.Dollars has a value of "1,000) > > Rick > > > > > > > > > ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:234391 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
RE: Ok, I give...how can I do this...
I didn't have any instructions either way. The only formatting I was using was with decimalformat so that we would have a number with 2 decimal places. CF put the comma there and then refused to recognize it as a number. Eric ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:234384 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=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
RE: Ok, I give...how can I do this...
I think it should. I have been having similar probs lately with CF7 where numbers that have commas in them are viewed as strings. I don't ever remember having this prob with previous versions...is this a new bug in 7? Eric -Original Message- From: Rick Faircloth [mailto:[EMAIL PROTECTED] Sent: Monday, 06 March 2006 17:56 To: CF-Talk Subject: Ok, I give...how can I do this... Should a field entry of "1,000" validate as a numeric? e.g. IsNumeric(Form.Dollars) (Where Form.Dollars has a value of "1,000) Rick ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:234383 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
Re: Ok, I give...how can I do this...
i hate to keep on beating a dead horse, but in CFMX7, you just use http://afpwebworks.com ColdFusion, PHP, ASP, ASP.NET hosting from AUD$15/month On 3/7/06, Rick Faircloth <[EMAIL PROTECTED]> wrote: > > What would be the best way to strip out > any content a person might enter besides > numerals, so that IsNumeric(Val(Form.Premium)) > would work? > > (I think I feel a Regex coming on...anyone?) > > Rick > > ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:234380 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
RE: Ok, I give...how can I do this...
What would be the best way to strip out any content a person might enter besides numerals, so that IsNumeric(Val(Form.Premium)) would work? (I think I feel a Regex coming on...anyone?) Rick > -Original Message- > From: Josh Nathanson [mailto:[EMAIL PROTECTED] > Sent: Monday, March 06, 2006 7:46 PM > To: CF-Talk > Subject: Re: Ok, I give...how can I do this... > > > You could do something like: > > IsNumeric(Replace(form.dollars, ",","","all")) > > That would remove any commas before applying the isNumeric test, so 1,000 > would be rendered as 1000 and pass the test (I think). > > -- Josh ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:234378 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=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
RE: Ok, I give...how can I do this...
Thanks for the tip, Josh...yet another way I'll have to validate an entry. Maybe it's just easier to let them make an illegal entry, then tell them how I want them to enter the data than try to catch all the possible violations... I wonder what will happen if they enter $1,000 and I run it against IsNumeric(Replace(Form.Dollars, ",","","all")) ? What about that dollar sign? I'll have to see...thanks, Josh... > -Original Message- > From: Josh Nathanson [mailto:[EMAIL PROTECTED] > Sent: Monday, March 06, 2006 7:46 PM > To: CF-Talk > Subject: Re: Ok, I give...how can I do this... > > > You could do something like: > > IsNumeric(Replace(form.dollars, ",","","all")) > > That would remove any commas before applying the isNumeric test, so 1,000 > would be rendered as 1000 and pass the test (I think). > > -- Josh ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:234362 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
Re: Ok, I give...how can I do this...
Ok, what's happening here ? What is C actually calculating? a="1,000"; b="2,000"; c=a*b; a=#a# b=#b# c=#c# This gives the following result: a=1,000 b=2,000 c=1500206316 I'd have thought C should be 2,000,000. So what's happening instead? Cheers Mike Kear Windsor, NSW, Australia Certified Advanced ColdFusion Developer AFP Webworks http://afpwebworks.com ColdFusion, PHP, ASP, ASP.NET hosting from AUD$15/month ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:234356 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=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
Re: Ok, I give...how can I do this...
You could do something like: IsNumeric(Replace(form.dollars, ",","","all")) That would remove any commas before applying the isNumeric test, so 1,000 would be rendered as 1000 and pass the test (I think). -- Josh - Original Message - From: "Rick Faircloth" <[EMAIL PROTECTED]> To: "CF-Talk" Sent: Monday, March 06, 2006 4:27 PM Subject: RE: Ok, I give...how can I do this... > Seems like I'll just have to give formatting instructions > not to put any commas in a field...on numerals. > > But that's not intuitive for someone making an entry > for $1,000,000...as 100...to difficult to tell > how many zeros are there...much easier as 1,000,000 > >> -Original Message- >> From: Rick Faircloth [mailto:[EMAIL PROTECTED] >> Sent: Monday, March 06, 2006 7:13 PM >> To: CF-Talk >> Subject: RE: Ok, I give...how can I do this... >> >> >> You know...I tried using IsNumeric(Val(Form.Dollars)), >> but found it was identifying a field entry of "wlekfjwlek" >> as numeric...I assume it was assigning a value of "0" >> to the entry and that is numeric... >> >> So that didn't weed out that kind of junk field entry >> in my validation (which is what I'm working on here... >> trying to validate an entry as a valid dollar entry. >> >> Rick >> >> >> > -Original Message- >> > From: Mike Kear [mailto:[EMAIL PROTECTED] >> > Sent: Monday, March 06, 2006 7:00 PM >> > To: CF-Talk >> > Subject: Re: Ok, I give...how can I do this... >> > >> > >> > No. numeral 1, comma, zero zero zero is a text string. But if >> you want to >> > make it a numeric value you can use #val("1,000")# . The >> > val() function >> > attempts to make a number out of whatever is in the string >> > submitted to it. >> > >> > Cheers >> > Mike Kear >> > Windsor, NSW, Australia >> > Certified Advanced ColdFusion Developer >> > AFP Webworks >> > http://afpwebworks.com >> > ColdFusion, PHP, ASP, ASP.NET hosting from AUD$15/month >> > >> > >> > On 3/7/06, Rick Faircloth <[EMAIL PROTECTED]> wrote: >> > > >> > > Should a field entry of "1,000" validate >> > > as a numeric? >> > > >> > > e.g. IsNumeric(Form.Dollars) >> > > >> > > (Where Form.Dollars has a value of "1,000) >> > > >> > > Rick >> > > >> > > >> > >> > >> > >> >> > > ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:234351 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=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
RE: Ok, I give...how can I do this...
Seems like I'll just have to give formatting instructions not to put any commas in a field...on numerals. But that's not intuitive for someone making an entry for $1,000,000...as 100...to difficult to tell how many zeros are there...much easier as 1,000,000 > -Original Message- > From: Rick Faircloth [mailto:[EMAIL PROTECTED] > Sent: Monday, March 06, 2006 7:13 PM > To: CF-Talk > Subject: RE: Ok, I give...how can I do this... > > > You know...I tried using IsNumeric(Val(Form.Dollars)), > but found it was identifying a field entry of "wlekfjwlek" > as numeric...I assume it was assigning a value of "0" > to the entry and that is numeric... > > So that didn't weed out that kind of junk field entry > in my validation (which is what I'm working on here... > trying to validate an entry as a valid dollar entry. > > Rick > > > > -Original Message- > > From: Mike Kear [mailto:[EMAIL PROTECTED] > > Sent: Monday, March 06, 2006 7:00 PM > > To: CF-Talk > > Subject: Re: Ok, I give...how can I do this... > > > > > > No. numeral 1, comma, zero zero zero is a text string. But if > you want to > > make it a numeric value you can use #val("1,000")# . The > > val() function > > attempts to make a number out of whatever is in the string > > submitted to it. > > > > Cheers > > Mike Kear > > Windsor, NSW, Australia > > Certified Advanced ColdFusion Developer > > AFP Webworks > > http://afpwebworks.com > > ColdFusion, PHP, ASP, ASP.NET hosting from AUD$15/month > > > > > > On 3/7/06, Rick Faircloth <[EMAIL PROTECTED]> wrote: > > > > > > Should a field entry of "1,000" validate > > > as a numeric? > > > > > > e.g. IsNumeric(Form.Dollars) > > > > > > (Where Form.Dollars has a value of "1,000) > > > > > > Rick > > > > > > > > > > > > > > ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:234346 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=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
RE: Ok, I give...how can I do this...
You know...I tried using IsNumeric(Val(Form.Dollars)), but found it was identifying a field entry of "wlekfjwlek" as numeric...I assume it was assigning a value of "0" to the entry and that is numeric... So that didn't weed out that kind of junk field entry in my validation (which is what I'm working on here... trying to validate an entry as a valid dollar entry. Rick > -Original Message- > From: Mike Kear [mailto:[EMAIL PROTECTED] > Sent: Monday, March 06, 2006 7:00 PM > To: CF-Talk > Subject: Re: Ok, I give...how can I do this... > > > No. numeral 1, comma, zero zero zero is a text string. But if you want to > make it a numeric value you can use #val("1,000")# . The > val() function > attempts to make a number out of whatever is in the string > submitted to it. > > Cheers > Mike Kear > Windsor, NSW, Australia > Certified Advanced ColdFusion Developer > AFP Webworks > http://afpwebworks.com > ColdFusion, PHP, ASP, ASP.NET hosting from AUD$15/month > > > On 3/7/06, Rick Faircloth <[EMAIL PROTECTED]> wrote: > > > > Should a field entry of "1,000" validate > > as a numeric? > > > > e.g. IsNumeric(Form.Dollars) > > > > (Where Form.Dollars has a value of "1,000) > > > > Rick > > > > > > > ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:234338 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=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
Re: Ok, I give...how can I do this...
No. numeral 1, comma, zero zero zero is a text string. But if you want to make it a numeric value you can use #val("1,000")# . The val() function attempts to make a number out of whatever is in the string submitted to it. Cheers Mike Kear Windsor, NSW, Australia Certified Advanced ColdFusion Developer AFP Webworks http://afpwebworks.com ColdFusion, PHP, ASP, ASP.NET hosting from AUD$15/month On 3/7/06, Rick Faircloth <[EMAIL PROTECTED]> wrote: > > Should a field entry of "1,000" validate > as a numeric? > > e.g. IsNumeric(Form.Dollars) > > (Where Form.Dollars has a value of "1,000) > > Rick > > ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:234330 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=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54