JSFiddle - React, Tailwind, and code Playground

by jury1

HTML

<input class="test" value='' placeholder="0 руб.">

JavaScript

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);
});