Tuesday, November 4, 2014

jquery number only

Posted by Gnani Palepu  |  2 comments

 how to allow only numeric in to the textbox using jquery  
 ----------------------------------------------------------  
 $(document).ready(function() {  
   allowonlynumeric();  
 });  
 function allowonlynumeric() {  
 $("#txtboxToFilter").keydown(function (e) {  
     // Allow: backspace, delete, tab, escape, enter and .  
     if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 ||  
        // Allow: Ctrl+A  
       (e.keyCode == 65 && e.ctrlKey === true) ||   
        // Allow: home, end, left, right  
       (e.keyCode >= 35 && e.keyCode <= 39)) {  
          // let it happen, don't do anything  
          return;  
     }  
     // Ensure that it is a number and stop the keypress  
     if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105))   
 {  
       e.preventDefault();  
     }  
   });  
 }  
 for any quries visit http://scriptquery.blogspot.in/  
 for any quries visit http://scriptquery.blogspot.in/  

1:02 AM Share:

2 comments:

Get updates in your email box
Complete the form below, and we'll send you the best coupons.

Deliver via FeedBurner
Proudly Powered by Blogger.
back to top