JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" class="myTexbox" />
JavaScript
$(document).ready(function() {
var oldVal = '';
$('.myTexbox').keypress(function (event) {
if (this.value.match("^[0-9]*[.,]?[0-9]{0,2}$"))
oldVal = this.value;
});
$('.myTexbox').keyup(function (event) {
if (!this.value.match("^[0-9]*[.,]?[0-9]{0,2}$")) {
$('.myTexbox').val(oldVal);
}
});
});