JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" class="thousandSeparator" />

JavaScript

function separator(comma, period) {
    comma = comma || ',';
    period = period || '.';
    var split = this.toString().split('.');
    var numeric = split[0];
    var decimal = split.length > 1 ? period + split[1] : '';
    var reg = /(\d+)(\d{3})/;
    while (reg.test(numeric)) {
        numeric = numeric.replace(reg, '$1' + comma + '$2');
    }
    return numeric + decimal;
}

$('.thousandSeparator').live('keyup', function () {
    $(this).val(separator.call($(this).val().split(' ').join(''), ' ', '.'));
});