JSFiddle - React, Tailwind, and code Playground
HTML
<input id="mobNumber" name="mobNmuber" type="text" />
JavaScript
$("#mobNumber").keydown(function (e) {
var id = $(this).attr('id');
$("#"+id).keypress(function(e) {
if ( (e.ctrlKey) || (e.which == 48 || e.which == 57) || (e.which == 95) || (e.which == 8) || (e.which == 32)
|| (e.which == 49 || e.which == 50) || (e.which == 51) || (e.which == 52) || (e.which == 53)
|| (e.which == 54 || e.which == 55) || (e.which == 56) || (e.which == 57) ||(e.which == 0)) {
}
else
{
e.preventDefault();
}
});
});