Follow the below example code and apply it in your code. hope it will work fine.
Html Code:
<input type="number" id="myInput" />
jQuery Code:
<script type="text/javascript"> $(document).on("change paste keyup",'#myInput' ,function(e) { var text=$(this).val(); if ($.isNumeric(text)) { if ((text.substring(text.indexOf('.')).length > 3) && (text.indexOf('.') > -1)) { e.preventDefault(); $(this).val(text.substring(0, text.indexOf('.') + 3)); } } else { e.preventDefault(); } }); </script>
Question and answer is powered by AnsPress.io