CalcBuilder Forum

Mask

User dhoeke 2026-01-30 13:58:19

Sorry, same subject.. but another question about masks.
Here is have a mortgage interest calculator.
Would be nice to have the currency € and percent % here in the fields.
I think the mask option is made for this (or maybe not). But when I put a mask on the first field being Money 2 and add a € sign in the prefix and I put the code in the before and after to remove the mask, then it either hangs in the calculation or the calculation goes wrong. When 400.000,00 is input then it calculates with 400..
And can you also get this mask (€) on the inline outputs?
Thanks for any info.

Moonsoft support 2026-01-30 15:01:21

Hi,
in order to add prefix or suffix, the mask is not the way to go, the mask is intended to format the input while user is typing, thus changing the characters and forcing you to 'undo' the formatting before making calculations. A number with thousand separator 400.000 is in fact a 400, because the point is the decimal separator of the numbers in php. So, you can also remove that point before doing your math, or, use the add ons feature to place a real prefix / suffix to the field without changing its value.
About the inline outputs, you're free to output any content, so if you have for ex:
$myvalue
already calculated, you can add any text or format before showing it at the page, at the end of the code
$myvalue="€".$myvalue;

or maybe

$myvalue="€".number_format($myvalue,2,".",",");

in order to show a formatted number with decimal and thousand separators, plus the € sign.


Hope this helps, regards
Guillermo V.
Moonsoft Team

User dhoeke 2026-01-30 15:33:06

Thanks! This worked perfect for the inline results. $myvalue="€".number_format($myvalue,2,".",",");

Now for the input fields I would like the same and you say:

So, you can also remove that point before doing your math, or, use the add ons feature to place a real prefix / suffix to the field without changing its value.

I think I get the removing part. That still is with the mask right I guess. And then remove it with the before calculation tab and place it back after calculation. I will try that.
But what do you mean by the add ons feature to place a real prefix/suffix?

Moonsoft support 2026-01-30 15:40:57

Hi,
the addon feature of the bootstrap library would the right solution, here the html you'd need to add to your fields

https://getbootstrap.com/docs/4.0/components/input-group/

Please check screenshot attached with a simulation of 2 addons placed on one of your fields, some styling may be needed but hope you get the idea of how do they work.

Regards
Guillermo V.
Moonsoft Team

User dhoeke 2026-01-30 15:47:09

Perfect many thanks. I also got to work the percentage field with the removal of the mask and then put it back after replacement. I will try this with the value of money as well. If that does not work I now understand the prefix thing.
Thanks again for now. Regards, Dennis

User dhoeke 2026-01-30 16:12:24

I see the masks are good but very strict. I would need the uses to be able to enter 200000 or 2000000 and it does not really seem to accept that. But I have to play around with it.
How would you remove the point before execution?

...
Support/development

Perfect for small code changes or to correct any bug at your site

Buy now!
...
Support/development 10 hours

Get a bigger amount of hours for more complex tasks and get a 10% discount

Buy now!