How do I split numbers into digits in JQuery?

  • 0
    I don't understand why the code doesn't work. When moving the sliders, an error pops up in the console
    The specified value "1 100 000" cannot be parsed, or is out of range.
    And the meanings themselves disappear ...
    What could be the reason?
    How can you fix this error?
    Or maybe you can somehow implement the division into digits in a different way?
    I really need help.

    <p class="sections">Бюджет:
                        <input type="number" min=0 max="2490000" value="1000000" id="min_price"
                               class="price-range-field" />
                        <input type="number" min="2500000" max="5000000" value="5000000" id="max_price"
                               class="price-range-field" />
                    </p>
                    <div id="slider-range"></div>

    $("#slider-range").slider({
        range: true,
        animate: true,
        min: 1000000,
        max: 5000000,
        values: [1000000, 5000000],
        step: 100000,
        slide: function (event, ui) {
            $("#min_price").val(ui.values[0].toString().replace(/\B(?=(\d{3})+(?!\d))/g, " "))
            $("#max_price").val(ui.values[1].toString().replace(/\B(?=(\d{3})+(?!\d))/g, " "))
        }
    });
    JavaScript Michael McMillan, Jan 28, 2020

  • 1 Answers
  • 0
    Everything, I decided myself. Didn't read the documentation correctly. Inputs needed text, not number
    Anonymous

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!