JSFiddle - React, Tailwind, and code Playground
HTML
<input id="p_first" type="text" value="" />
<br />
<input class="numbersOnly" type="text" value="" />
JavaScript
$('#p_first').keyup(function(event){
if(isNaN(String.fromCharCode(event.which))){
var value = $(this).val();
$(this).val(value.substr(0,value.length-1));
}
});
jQuery('.numbersOnly').keyup(function () {
this.value = this.value.replace(/[^0-9\.]/g,'');
});