JSFiddle - React, Tailwind, and code Playground

by manoj

HTML

<input type="text"  onkeyup="return checkDec(this)" />

JavaScript

function checkDec(el){
 var ex = /^[0-9]+\.?[0-9]*$/;
 if(ex.test(el.value)==false){
   el.value = el.value.substring(0,el.value.length - 1);
  }
}