JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" maxlength="12" name="price" id="price" class="foo">
JavaScript
$('#price').change(function() {
$(this).val($(this).val().match(/\d*\.?\d+/));
});
<input type="text" maxlength="12" name="price" id="price" class="foo">
$('#price').change(function() {
$(this).val($(this).val().match(/\d*\.?\d+/));
});