How to make it so that if there are more than two zeros in the number, it is separated by spaces, that is: 100 <2, 1 000> 2, 1 000 000> 2, etc. ?
And somehow it is easier to arrange the insertion of the ruble symbol at the end of the input? There is such a solution, but it seems to me a bit wrong, because removed hard value.
function addRub (val) { return val + " ₽"; } function removeRub (val) { val = val.replace(" ₽", ""); val = val.replace("₽", ""); val = val.replace(" ", ""); return val; } $(".test").on("input", function () { var $this = $(this); var val = $this.prop("value"); var newVal = removeRub(val); newVal = addRub(newVal); $this.prop("value", newVal); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <input class="test" value='₽'>