JSFiddle - React, Tailwind, and code Playground
by pcgupta17
HTML
<label for="txtAny">gms</label>
<input name="txtAny" id="txtAny" class="customonly" />
JavaScript
jQuery.fn.forceNumeric = function () {
return this.each(function () {
$(this).keydown(function (e) {
var key = e.which || e.keyCode;
if (!e.shiftKey && !e.altKey && !e.ctrlKey && key >= 48 && key <= 57 || key >= 96 && key <= 105 || key == 8 || key == 9 || key == 13 || key == 35 || key == 36 || key == 37 || key == 39 || key == 46 || key == 45) return true;
return false;
});
});
}
$(document).ready(function () {
$('.customonly').forceNumeric();
});