Copy link to clipboard
Copied
French dollar amount text field entry, enter Keystroke period or comma, becomes comma in text field.
Currently my scripts do this:
If I type 12345, it converts to 12345,00 not 123,45
If I type 123,45, it remains 123,45, which is fine for French.
If I type 123.45, the period is unavailable. I must use the comma otherwise the amount would show as: 12345,00 instead of 123,45, it will automatically add zero cents.
I have 2 functions to a document level JavaScripts for the French dollar amounts.
FORMAT SCRIPT
function fr_format_decimal() {
AFNumber_Format(2, 2, 0, 0, "", false);
event.value = event.value.replace(/\./g, " ");
}
KEYSTROKE SCRIPT
function fr_keystroke_decimal() {
AFNumber_Keystroke(2, 2, 0, 0, "", false);
}
TEXT FIELD PROPERTIES / FORMAT / CUSTOM
Custom Format Script
// Custom Format JavaScript
fr_format_decimal();
Custom Keystroke Script
// Custom Keystroke JavaScript
fr_keystroke_decimal();
I need to be able to type a "comma" or "period" and have it end up French (Comma).
1234.50 or 1234,50 = 1234,50
I am not very good with scripts, any help I can get to make this work would be greatly appreciated.
Many Thanks.
I figured out how to make this work.
Prepare form/Properties
In the format, custom, custom keystroke script I REMOVED the document level script request.
Custom Keystroke Script
// Custom Keystroke JavaScript
fr_keystroke_decimal();
and ADDED:
event.value = event.value.replace(/\./g, ",");
now I can enter either or and end up French
1234.50 or 1234,50 = 1 234,50
Copy link to clipboard
Copied
So you want to enter the number using the North American notation and have it automatically convert to the European notation?
That can be a difficult proposition. Do you assume the user always enters in NA format, or could it be either? are there always 2 decimal places? What happens if the user enters 3 decimal places, or none? This gets really complicated, especially if the user is entering a thousands separator. The first thing you need to do is to go through all the possible scenarios for a user entering data and how you want them handled. There can be no hand waving scenarios. There has to be an exact predictable outcome for each possible input scenario.
For example, there is no way to predict what key the user will hit next, so there is no way to covert on the fly as the user enters data. The best way to do this is to convert when the user commits the value.
Copy link to clipboard
Copied
We have a small group of English and French speaking completing this form.
There will always be two decimal places, thats it. They will not be entering a thousands separator.
I need to be able to type a "comma" or "period" and have it end up French (Comma).
1234.50 or 1234,50 = 1234,50
Copy link to clipboard
Copied
I figured out how to make this work.
Prepare form/Properties
In the format, custom, custom keystroke script I REMOVED the document level script request.
Custom Keystroke Script
// Custom Keystroke JavaScript
fr_keystroke_decimal();
and ADDED:
event.value = event.value.replace(/\./g, ",");
now I can enter either or and end up French
1234.50 or 1234,50 = 1 234,50