Affects Version/s: 1.5, 1.6
Fix Version/s: 1.6
Implement a utility function for validating all monetary input fields which does the following:
- Strip out all characters that are NOT digits, dots or commas
- Strip out the locale-specified thousands separator (mon_thousands_sep) [e.g. comma for US, etc.]
- Now verify that we have an "at-most-two-decimal-digit float" based according to the given locale decimal_separator (mon_decimal_point). (Might want to replace locale-specified decimal point with a standard one - e.g. the dot - and then validate...).
[This way we always end up with either an empty string, somthing that has too many decimal digits, or a proper amount.]
Once implemented - we should invoke this for custom fields with type = Money, as well as built-in monetary input fields. These include:
- Other Amount - Contribute/Contribution/Main.php
- All amount fields in add/edit contribution form
- Amount fields in Manage Premiums forms
- All the amount fields in the configure Contribution Amounts for a contribution page
- Membership fee (add/edit membership type)
---- original post from R Monks -----
It's not unusual for people to space out numbers like:
All of these are nine thousand, nine hundred and ninety-nine dollars and ninety-nine cents. Since CRM uses . to designate the cents spacing it shouldn't complain when a comma is used after every third number as in example #1. At the very least, commas could be stripped out from input.