Page 1 of 1
Number Formating
Posted: Wed Aug 28, 2013 9:00 pm
by mpol_ch
Hello
I am using the following number formating with PHPMAKER 10:
74'280'305,00
I am using the following script to autocalculate the field on change. The numbers are in formation such 89000.75 and PHPMAKER is claimin that the format of number is not correct.
Is there a way use the number of formating easily for this script?
thanks
mpol_ch
$("#x_Vortrag").change(function() {
var p1 = $("#x_Vortrag").val();
var p2 = $("#x_Betraege").val();
var sump = +p1 + +p2;
var m1 = $("#x_Leistungen").val();
var m2 = $("#x_Anlagen").val();
var summ = +m1 + +m2;
$("#x_Endbestand").val((+sump - +summ).toFixed(2)) ;
Re: Number Formating
Posted: Thu Aug 29, 2013 11:36 am
by mobhar
Make sure the field type is double, and the number format has been setup to double from Fields setup.
Re: Number Formating
Posted: Thu Aug 29, 2013 11:38 am
by danielc
The validation is based on your decimal separator defined. In your case, it is ",". So, you need to use str.replace(".", ",") to change the decimal separator to pass the validation.
Re: Number Formating
Posted: Thu Aug 29, 2013 5:58 pm
by mpol_ch
Hallo danielc
thankd for the hint. Where should I just insert the replace code? Is the following code correct?
$("#x_Endbestand").val((+sump - +summ).toFixed(2)).replace(".", ",") ;
mpol_ch
Re: Number Formating
Posted: Fri Aug 30, 2013 11:26 am
by danielc
Try:
$("#x_Endbestand").val(((+sump - +summ).toFixed(2)).replace(".", ",")) ;
Re: Number Formating
Posted: Fri Aug 30, 2013 6:45 pm
by mpol_ch
Dear danielc
thanks a lot for your input. It is working perfectly.
Just another question: Is that possible to format in same way to separate the thousand numbers?
Exp: 5234056,67 should be 5'234'056,67
Thanks any way.
mpol_ch
Re: Number Formating
Posted: Sat Aug 31, 2013 9:35 am
by danielc
You can refer to ewp10.js under phpjs subfolder and search for "//Add the thousands separator".