I am using the jquery ui range slider.
Trying to add comma to the numbers so it will bore readable.
tried like yo different ways including regex and parseFloat
but without success.
this is the jsfiddle.
I am using the jquery ui range slider.
Trying to add comma to the numbers so it will bore readable.
tried like yo different ways including regex and parseFloat
but without success.
this is the jsfiddle.
This is what you want ? https://jsfiddle.net/sxd60y6x/
NUMBER.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")
See : How to print a number with commas as thousands separators in JavaScript
You can use toLocaleString method.
Here is how your code should look like.
$("#slider-range").slider({
range: true,
min: 10000,
max: 10000000,
values: [1000000, 4000000],
slide: function(event, ui) {
var minVal = ui.values[0].toLocaleString();
var maxVal = ui.values[1].toLocaleString();
$("#amount").val("₪" + minVal + " - ₪" + maxVal);
}
});
And you need to do the same to your initial value code.
$("#amount").val("₪" + $("#slider-range").slider("values", 0).toLocaleString() + " - ₪" + $("#slider-range").slider("values", 1).toLocaleString());