Reg - toLocaleString()
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2023 12:57 AM
Hi All,
I'm using the below script to make the field to display a number as currency of USD and AUD .
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var num = new Number(g_form.getValue('<your_field>')),
result = num.toLocaleString("undefined", {
style: "currency",
currency: "USD"
});
g_form.setValue( result);
}
}
But it is throwing NaN error. Can anyone help me out this.
If the field is filled as '9807687' then it should display as '$9807687 USD'
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2023 01:25 AM
Use the code below @Jai2021
var num = new Number(g_form.getValue('fieldName'));
var result = num.toLocaleString("en-US", {
style: "currency",
currency: "USD"
});
g_form.setValue('field_name',result);Please mark as correct if it helps.
