floating number validation and locale settings

Hi all,

I’m getting a “Incorrect floating point number” error message while inserting, editing or searching a field validated as float. If I use the standard english.json locale settings I get no error, even when I write a value without thousands separator, “100000” for instance (minus the quotes, naturally).
However, with my customized portuguese locale settings, I always get the error for that “100000” value, except if I write it using the english characters: “100,000”. No error there, BUT, my thousands separator is the space character and the error comes back if I write “100 000”.
My pt.json locale file is:

{
“date”: “2019-08-05”,
“version”: “16.0.0”,
“id”: “pt”,
“locale”: “pt_PT”,
“name”: “Portuguese (Portugal)”,
“desc”: “Portuguese (Portugal)”,
“author”: “Me”,
“decimal_point”: “,”,
“thousands_sep”: " ",
“mon_decimal_point”: “,”,
“mon_thousands_sep”: " ",
“currency_symbol”: “€”,
“positive_sign”: “”,
“negative_sign”: “-”,
“frac_digits”: 2,
“p_cs_precedes”: 0,
“p_sep_by_space”: 0,
“n_cs_precedes”: 0,
“n_sep_by_space”: 0,
“p_sign_posn”: 1,
“n_sign_posn”: 1,
“date_sep”: “-”,
“time_sep”: “:”,
“date_format”: “Ymd”,
“time_zone”: “Europe/Lisbon”
}

client side returns error when the space is used as thousands separator (100 000). It gives no error if I use no thousands separator (100000), but it that case the error is on the server side validation. The only way to pass both validations is to use the english thousands separator (100,000), but that is wrong for my locale settings.

I’d appreciate a solution for this. Cheers!

Make sure the language id of your language file matches your locale file name, e.g. if your language file has id=“pt”, then your locale file should be pt.json, not pt_PT.json.

I checked that. Filename is pt.json and LANGUAGE_DEFAULT_ID in ewcfg.php is “pt”. Problem is elsewhere. Also, the language id in the language xml file is “pt”.

Are you sure you have generated and uploaded the pt.json in the “locale” folder to your server? Check your locale file under \locale.

Yes, its very contents is what I pasted in the first message.

The thousands separator should be optional on user input. Oddly, when I edit a record and write “100100,00” I get a server side validation error and get the edit page back again, but now the value appears with the thousands separator: “100 100,00”. So, after the error, if I submit the form again without changing the value it is successfully saved.

I tried to test by copying your locale file, name it pt.json and change my language file id to “pt”, the server validation accepted both “100 000” and “100000” fine.

Thanks for your test. Still, it just doesn’t work here.
Some more info: PHP version is 7.2; database is SQL Server; field is numeric(18,2); formatted as currency, 2 digits after decimal. Using in Firefox and Chrome with equal results. PHP Maker 16, fully updated.
Another thing I noticed is that the three options of the currency format (include leading digit, use () for negative nos, group digits using delimiter) are black squares. What is the difference between the black squares and the ticked boxes? What should be the correct setup? I tried some variations and it didn’t seem to make a difference.
I couldn’t find an explanation for these settings in the field setup chapter of the help documentation.
Thanks and please help.

An interesting update, that may shed some light to the problem:
I edited the pt.json file and altered thousands_sep and mon_thousands_sep to empty strings. Then, I edited the record and wrote 123123,45 to the field.
Upon submit, I got no error, but now the field shows 12,312,345,00 € (view page) and 12312345,00 (edit page). So, there’s definitively some problem.
Question: are the actual server locale settings a factor in this? This could explain why Arbei could not reproduce my problem. I’m using Windows Server 2016 and IIS with portuguese locale settings.

Windows locale setting should not affect PHPMaker locale settings. You should check the pt.json on your server and make sure it is not corrupted during upload. I suspect that you have used some editor which uses some unicode characters instead of using utf-8. Make sure the pt.json is in utf-8 encoding and the space is char(32), not unicode characters.

I will, thanks.