JSFiddle - React, Tailwind, and code Playground

by Yure Pereira

HTML

<form>
  <input type="text" data-text-mask="http://" id="txt_numeric">
</form>

JavaScript

$.fn.onlyNumeric = function (e) {

    $(this).on('keyup keypress focus', function () {

        var field = $(this);
        var textLength = text.length;

        if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {

            e.preventDefault();
            return false;

        }

    });

    return this;

};