TOPIC:

Replace comma with point for calculation 2 weeks 4 days ago #242837

  • Topic Author
  • macross
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 30
  • Thanks: 0
Perfect, thanks a lot!

Please Log in or Create an account to join the conversation.

Replace comma with point for calculation 2 weeks 4 days ago #242838

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Posts: 233
  • Karma: 3
  • Thanks: 40
Hi,

np, anyway. :)

If you didn't do already, please keep us motivated by leaving a small review here:
extensions.joomla.org/extension/contacts...orms/breezing-forms/
(Please turn off your VPN and local Apache prior reviewing as your review might get blocked)

Thanks and regards,
Tihana

Please Log in or Create an account to join the conversation.

Last edit: Post by tihana.krivic.

Replace comma with point for calculation 4 days 3 hours ago #243807

  • Topic Author
  • macross
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 30
  • Thanks: 0
Hello again,

More issues with this came up.

1) Regarding the calculation:
Seems like people also tend to input 1.000,99 (for example) - so with a dot for the thousand mark. That results in NaN, while inputing 1.000 results in 1 for the calculation.

My current code is
var VS1 = ff_getElementByName('V1').value.replace(/,/g, ".");
I tried to put also
.replace(/./g, "")
in addition to the one that I already have, but that results in the calculation always displaying 0.
Probably because
.replace(/,/g, ".")
comes right afterwards.

How could I solve this?

2) Regarding the output.
Since people also input numbers with a lot of zeros (like 10000) it should display 10.000 (with a point) in their input field.
My code looks like this
var VS1 = ff_getElementByName('V1').value.replace(/,/g, ".");
so I tried to find a solution with
.toLocaleString('de-DE');
but couldn't actually figure it out.

Thanks and regards

Please Log in or Create an account to join the conversation.

Replace comma with point for calculation 3 days 21 hours ago #243832

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Posts: 233
  • Karma: 3
  • Thanks: 40
Hi,

I am not tested it but please try:
1)
.replace (/,/g, "." | (/./g, " "));
2)
.toLocaleString("de-DE");

Let me know if it helps.

Regards,
Tihana

Please Log in or Create an account to join the conversation.

Last edit: Post by tihana.krivic.

Replace comma with point for calculation 3 days 2 hours ago #243875

  • Topic Author
  • macross
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 30
  • Thanks: 0
For me it did not work but after some testing I found a solution for
1)
(in case someone has the same problem)
.replace(/\./g, '').replace(/\,/g, '.');
so that's solved.

2)
I figured out that my problem did not come from
.toLocaleString("de-DE");
but instead from
.toFixed(2);
so I came up with
.toLocaleString('de-DE', {    
minimumFractionDigits: 2,    
maximumFractionDigits: 2});
and that solves it for me.

3)
The only question I am left with is: This solution (2) works only for the total, but it cannot change the users input directly. I put a screenshot for you to see what I mean.

In the best case it should also change the input to say 4.050,30 €

I tried
.toLocaleString("de-DE");
or
.toLocaleString('de-DE');
in the actual action script and also in the initialization script but both did not work.
For testing purposes I made the initialization script change my input directly to another number, that worked, so it's not about the initialization script but rather the code itself.

Thanks for your support - again!
Attachments:

Please Log in or Create an account to join the conversation.

Last edit: Post by macross.

Replace comma with point for calculation 3 days 2 hours ago #243876

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Posts: 233
  • Karma: 3
  • Thanks: 40
Hi,

did you try to add this on total and others inputs (summe1 and summe2)?

Regards,
Tihana

Please Log in or Create an account to join the conversation.

Last edit: Post by tihana.krivic.
Moderators: ForumSupport
Time to create page: 0.053 seconds

July Sale!

Discounts for all of our extensions + support. Ending July 31st!

Get Your Subscription Here

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Special Offer

Summer Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!