JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" id="txt" />
JavaScript
$('#txt').keypress(function (e) {
var key = String.fromCharCode(e.which);
var pattern=/^[0-9]{1,11}(,[0-9]{0,2})?$/;
var txt = $(this).val() + key;
if (!pattern.test(txt)) {
e.preventDefault();
}
});