<input type="text" id="nnn"> <script> nnn.oninput = function() { this.value = Math.round(+this.value)||0;} </script>