JSFiddle - React, Tailwind, and code Playground
HTML
<input>
JavaScript
$.fn.mask = function(regex) {
this.on("keypress", function(e) {
if (regex.test(String.fromCharCode(e.which))) {
return false;
}
});
}
$("input").mask( /\d/ );