JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Round to 4 Decimal Places</title>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jQuery/jquery-1.4.2.min.js"></script>
</head>
<body>
<p>Type a decimal number in the TextBox, limited to 4 decimals</p>
<input id="input" type="text" />
</body>
</html>
JavaScript
$(function() {
$('#input').keypress(function(){
try {
val = $(this).val().split('.');
if(val[1] > 999) return false;
}catch(e){}
})
});