JSFiddle - React, Tailwind, and code Playground
HTML
<html>
<head>
<title></title>
<script type="text/javascript" src="jquery-min.js"></script>
<style>
input{font-size: 30px;}
</style>
<script>
(function($){
String.prototype.addComma = function() {
return this.replace(/(.)(?=(.{3})+$)/g,"$1 ")
}
$.fn.digits = function () {
return this.each(function () {
$(this).val($(this).val().replace(/( | )/g,'').addComma());
})
}
})(jQuery)
jQuery(function(){
$('input[type=text]').bind('blur keyup',function(){ $(this).digits(); }).digits();
});
</script>
</head>
<body>
<input type="text" placeholder="Type a Number" />
</body>
</html>