JSFiddle - React, Tailwind, and code Playground

by Vladimir Zharinov

HTML

<input type="text" id="number" />

JavaScript

$('#number').on("keyup", function() {
    this.value = this.value.replace(/ /g,'');
    var number = this.value;
    this.value = number.replace(/\B(?=(\d{3})+(?!\d))/g, " ");
});