-2

I need to allow only floating or number value in textbox allow only 0-9 & signal dot(.) maximum 5 length.

For e.g.: 12.02, 12345, 2.324, 0.254, .1234

1 Answers1

-1

jQuery(document).ready(function() {
    $('.float-numbers').keypress(function(event) {
        if ((event.which != 46 || $(this).val().indexOf('.') != -1) && (event.which < 48 || event.which > 57)) {
            event.preventDefault();
        }
    });
});
<html>
  <header>
    <title></title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  </header>
  <body>
    Enter Number:
    <input type="text" class="float-numbers" maxlength="5" name="numbers" value="">
  </body>
</html>
Nirav Sutariya
  • 317
  • 4
  • 14