JSFiddle - React, Tailwind, and code Playground

HTML

<input type = "text" id = "my_textbox" maxlength = "4">

CSS

#my_textbox{
    position: absolute;
    top: 50px;
    left: 100px;
    height: 30px;
    width: 200px;
}

JavaScript

$("#my_textbox").keyup(function(){
    if($("#my_textbox").val().length == 4){
        var my_val = $("#my_textbox").val();
        $("#my_textbox").val(Number(my_val).toLocaleString('en'));
    }
});