You are viewing limited content. For full access, please sign in.

Question

Question

Javascript: Regex help

asked on October 4, 2022

Hello,

I have a Number field in Table which holds Amount.

I want to have the amount to be shown as:

100.00

1'000.00

10'000.00

100'000.00

1'100'000.00

 

Can some please help?

 

I have the issue is that if I format the field with Token in WF then it formats all the values contained in multivalue field, so I want to format in the form itself & then pass to WF.

 

 

0 0

Replies

replied on October 4, 2022

I found this: 

https://answers.laserfiche.com/questions/78025/How-can-we-format-currency-fields-in-Forms-to-use-commas#78287

 

This is the code I have, 

 $(document).ready(function () {
  
 $('.commas input').attr("pattern", '^(\\d+|\\d{1,3}(,\\d{3})*)(\\.\\d{2})?');
  
  $('.commas input').on("change", function () {
   $(this).val($(this).val().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1'"));
  });
  
});

I added a SingleLine field & mapped the Amount to it, these are the 2 problems I am facing:

1. It only applies to the 1st Row :(

2. If in the amount there is no decimal, the mapped filed doesn't show .00

 

Can someone please help.....?

 

Regards,

0 0
replied on October 5, 2022

Hello,

Can someone please help?

 

 

0 0
replied on October 10, 2022

For both number and currency field, there is option of "use thousands delimiter" and number field has option to specify the decimal places to 2 as well.

With the out of box options, you can format the value into something like 1,000.00

Is there any special reason you want to use ' instead of , as thousand delimiter? 

 

0 0
replied on October 11, 2022

The format of number in CH is with '

0 0
replied on October 11, 2022

There is a global settings available for number/currency format on the Forms server that will affect all forms.  C:\Program Files\Laserfiche\Laserfiche Forms\Forms\Settings\numberFormat.json.

You can update the value for separatorChar to change the thousand delimiter for your language. You can also add new locale to the list following the same format if your language is not listed. After update the numberFormat.json, you need to clear your browser cache to make it use the updated settings. 

If you don't know what is the language of your browser. You can open the browser developer tools, go to Network tab, then load a forms page and check the accept language for any Forms request.

0 0
replied on October 11, 2022

Thanks!

I forgot to.mention this is cloud

0 0
replied on October 13, 2022

For cloud this is no such configuration available, you need to do it with JavaScript.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.