<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <script> $(function(){ $('.number_dots').on("keyup", 'input', function(){ this.value = this.value.replace(/^\0|[^\d]/g, ''); }); }); </script>