[Custom Masks] Currency mask without 2 decimals digits

[Custom Masks] Currency mask without 2 decimals digits

  
Forge Component
(24)
Published on 19 Sep by Marcelo Ferreira
24 votes
Published on 19 Sep by Marcelo Ferreira

Mask Currency component in https://www.outsystems.com/forge/component/647/custommasks/, as we can see in its Demo, works as expected:

- Initialy "$ 0.00"

- If we put "1" shows "$ 1.00", "1.2" shows "$ 1.20"

But I can't replicate this behavior in my local factory.

It happens something like in https://labsdev.outsystems.net/CustomMasks/

- Initialy "$ 0"

- If we put "1" shows "$ 1", "1.2" shows "$ 1.2"


Help please!

Same problem here!

When I put 55.00 it changes to 55 and I have the requirement to keep it 55.00

Solution

@Paulo Sousa try putting in the Advanced Options : 

SyntaxEditor Code Snippet

"{autoUnmask:true, placeholder:""0"",digitsOptional:false}"

It works for me!

Solution

It works!


Thank you very much Nelson.


Now I still have a litle problem:

When I put a value in the variable, and refresh the control, from that moment the mask stops working properly.


Any idea how to overcome this?


Hi Paulo,

Are you refreshing the mask too? You need to refresh the control and the mask. Put both on a Container and refresh that container.

Regards,

Marcelo

That's it Marcelo.

Thank you very much.

Beste regards,

Paulo

Nelson André wrote:

@Paulo Sousa try putting in the Advanced Options : 

SyntaxEditor Code Snippet

"{autoUnmask:true, placeholder:""0"",digitsOptional:false}"

It works for me!

Thanks for posting this.  For me the "placeholder:""0"",digitsOptional:false" option is causing strange behavior.  When you are typing in certain locations in the input field, your cursor jumps to the end of the field as well as you cannot use the backspace key to erase digits.  Is there another way to accomplish having ".00" displayed at the end of the number even if the value is a round number like "100"?


David Austin wrote:

Nelson André wrote:

@Paulo Sousa try putting in the Advanced Options : 

SyntaxEditor Code Snippet

"{autoUnmask:true, placeholder:""0"",digitsOptional:false}"

It works for me!

Thanks for posting this.  For me the "placeholder:""0"",digitsOptional:false" option is causing strange behavior.  When you are typing in certain locations in the input field, your cursor jumps to the end of the field as well as you cannot use the backspace key to erase digits.  Is there another way to accomplish having ".00" displayed at the end of the number even if the value is a round number like "100"?


I found this cursor-jumping behavior is caused by having an OnChanged action on the input field.  The OnChanged action does not modify or Ajax-refresh the field, but in any case my error was not caused with the solution above.  A related post is here.