It sounds like you're taking the 'high road' approach to this (i.e., letting users enter arbitrary currency strings and then trying to figure out the currency type after the fact and then checking the thousands separators and decimal point characters to see if they match that). That's a best practice usability-wise (at least if you agree with Alan Cooper...), but it can also take a lot of code to implement it robustly and it requires thorough testing.
If you're willing to trade off some usability, you could have user's pick the currency type (i.e., USD, Euro, Yen), _separately_, say in a drop-down list; and then have them enter the actual value (in a separate text field). If you implement it that way, then your (currency) string parsing problem becomes much simpler. If you put the currency type selector _before_ the amount field (in the workflow/tab order), then you can also do things like dynamically changing the validator for the amount field, based on the selected currency. You could even have a 'no currency type selected' default for the currency type selector and disable the amount field until the user selected a particular currency. I don't know if I would consider the latter approaches as 'best practices' (especially from a usability perspective), but they are reasonable trade-offs. YMMV. I'm not quite clear on what you're trying to do formatting wise, however. Are you saying that you try to detect when a user has finished entering a currency amount, and then add currency symbols, thousands separator symbols, decimal point symbol, etc.? Regards, Jim --- In [email protected], "flexcoder2008" <[EMAIL PROTECTED]> wrote: > > What is the best practice or a good recommendation for formatting > currency values and then removing the currency formatting for saving > to the database? > > Here's what I have attempted to do so far. It works - but only if the > user enters plain old numbers - if they add any currency symbol or > thousand separator, it fails. > > I have a form which has some textInput's that are formatted with > currencyFormatters. I initialize each textInput's .data property to > "0". The textInput displays formatted currency amounts from xml data > retrieved from the database. On the focusIn event, the text property > is assigned to the textInput's .data property, so the value stays the > same but the formatting is gone. And when a change event fires, the > unformatted text in the textInput gets updated to the data property as > well. > > On the FocusOut event, the currency formatting is re-applied. > > When I save to the db, I use the textInput's .data property. So for > the most part this works, but fails if the user enters any currency > symbols. > > Is there a good class or function someone could recommend to take a > currency value in a textInput and strip out all the extra formatting > characters? I am also trying to implement localization, so the > various currency symbols will be different depending on the locale. > > Thanks >

