JSFiddle - React, Tailwind, and code Playground

HTML

<label>Digits Only:
  <input type="text" />
</label>
<br>
<br>

JavaScript

$(function() {
  $('input').bind('keyup', function(event) {
    var currValue = $(this).val();

    if (currValue.search(/[^0-9]/) != -1) {

      alert('Only numerical inputs please');
    }

    $(this).val(currValue.replace(/[^0-9]/, ''));
    alert($(this).val());
  });
});