JSFiddle - React, Tailwind, and code Playground
by praveenti
HTML
<script src="widget.js"></script>
<script src="jqueryui"></script>
<input name="pricePerHour" id="pricePerHour" type="number" class="form-control" placeholder="Price Per Hour" required />
<br><br>
<input name="pricePerHour" id="costPerHour" type="text" class="form-control" placeholder="Cost Per Hour" required />
JavaScript
$("#pricePerHour,#costPerHour").on("keyup", function() {
var valid = /^\d{0,4}(\.\d{0,2})?$/.test(this.value),
val = this.value;
if (!valid) {
this.value = val.substring(0, val.length - 1);
}
});