Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

priceToFloat error value when changed centsSeparator and thousandsSeparator #64

Open
paulop opened this issue Mar 20, 2017 · 2 comments

Comments

@paulop
Copy link

paulop commented Mar 20, 2017

$("#amount").priceFormat({
	prefix: "R$ ",
	centsSeparator: ",",
	thousandsSeparator: "."
});

alert($('#amount').priceToFloat() );

using this code priceToFloat() return a wrong value.

Thanks!

@oguzhanaksoy
Copy link

oguzhanaksoy commented May 22, 2017

Hi,
I write external method in js file:

$.fn.customizePriceToFloat = function() {
  if ($(this).is('input'))
    field = $(this).val() || [];
  else
    field = $(this).html();
    field = field.replace(/([^,\d])/g,''); // All dot clean
    field = field.replace(/\,(?=[^.]*$)/, "."); // last comma convert to dot
    return parseFloat(field); // convert
};

@rodrigotxt
Copy link

rodrigotxt commented Jul 23, 2017

image

I also had problem with this function (in Firefox). The solution I found was to redefine the function (when submitting the form) to:

$ ('#value'). PriceFormat ({
     Prefix: '',
     CentsSeparator: '.',
     ThousandsSeparator: ''
});

That way it's like float.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants