JSFiddle - React, Tailwind, and code Playground

HTML

<input>

JavaScript

$.fn.disallowChars = function(regexp){
  this.keypress(function(e){
      console.log(String.fromCharCode(e.which));
   if(String.fromCharCode(e.which).match(regexp)) return false;
  });
  return this;
};

$("input").disallowChars(/\D/g);