IonDen / ion.rangeSlider

jQuery only range slider
http://ionden.com/a/plugins/ion.rangeSlider/en.html
MIT License
2.56k stars 508 forks source link

Comma causes the slider to go to zero. #747

Closed arnonrdp closed 2 years ago

arnonrdp commented 3 years ago

I believe I found a low priority bug. I have a slider with number inputs. And I am replacing dots for commas on decimals. To do it I am using this:

prettify: function (num) {
  var n = num.toString();
  n = n.replace(".", ",");
  return n.replace(/(\d{1,3}(?=(?:\d\d\d)+(?!\d)))/g, "$1\.");
}

But for some reason when a type a comma on input, the slider immediately leads to zero. You can check it right here on the website I am working on.

IonDen commented 3 years ago

Why do you mess with dot and comma? In javascript dot is a standard.

But if you really want this, if your local standards says that it should be comma - you should do a double conversion.

1 - then you put value to input 2 - then you read value from input

That means that input value will be always a string, not number. And if you will pass string to the slider as-is. It will be automatically parsed to number but standard rules. But you don't want that, you will need to parse it manually and pass already parsed number to slider.