Showing posts with label Jquery for check float numbers on keypress event. Show all posts
Showing posts with label Jquery for check float numbers on keypress event. Show all posts

Wednesday, May 4, 2016

Jquery for check float numbers on keypress event

Script

 <script type="text/javascript">  
     $(document).ready(function () {  
 $('.isFloat').keypress(function(event) {  
  if ((event.which != 46 || $(this).val().indexOf('.') != -1) && (event.which < 48 || event.which > 57)) {  
   event.preventDefault();  
  }  
 });  
  });  
 </script>  

 <asp:TextBox ID="txtTotlaMark" runat="server" pattern="^[0-9 .]{1,}$" class="isFloat" MaxLength="6" required></asp:TextBox>