JSFiddle - React, Tailwind, and code Playground
by BuriB
HTML
<input />
JavaScript
// user can only type in numeric values from 1-9
// 0 is not allowed.
function sanitizePriceFields(e) {
var key = e.keyCode || e.charCode || e.which;
if ( !( key > 48 && key <= 57 || key === 8 || key === 9 || key === 13 || key === 46 ) ) {
e.preventDefault();
}
}
$('input').bind("keypress", sanitizePriceFields);