JSFiddle - React, Tailwind, and code Playground
by kang cahya
HTML
<script src="//code.jquery.com/jquery-1.12.0.min.js"></script>
<form name="atur_harga" action="" method="POST">
<label for="desimal">Input Desimal :</label>
<input type="text" class="harga" id="desimal" value="">
</form>
JavaScript
$(".harga").on("keyup", function(){
var valid = /^\d{0,15}(\.\d{0,2})?$/.test(this.value),
val = this.value;
if(!valid){
console.log("Invalid input!");
this.value = val.substring(0, val.length - 1);
}
});