Thursday, 22 June 2017

Check for Float value on keypress using JQuery ~ GNIITHELP

Following is script by which you can put check for float value.





html input field on which you want to put check for float value: 
 <input class="checkfloat" type="text">  

Script for Float Value check: 
 $(".checkfloat").on("keypress keyup",function (event) {  
     $(this).val($(this).val().replace(/[^0-9\.]/g,''));  
     if ((event.which != 46 || event.which == 8 || event.which == 9 || $(this).val().indexOf('.') != -1)   
               && ((event.which < 48 || event.which > 57))) {  
       event.preventDefault();  
     }  
   });  

No comments:

Post a Comment