Click here to Skip to main content
15,887,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi

I have a JavaScript function to allow number ,backspace which I use on Key Press Event. This is not allowing tab key to work. Please help

C#
function allownumbers(e) {
          var key = window.event ? e.keyCode : e.which;
          var keychar = String.fromCharCode(key);
          var reg = new RegExp("[0-9.]")
          if (key == 8) {
              keychar = String.fromCharCode(key);
          }
          if (event.keyCode == 9) {
              //TAB is pressed keyCode = 9 for TAB key
              return
          }




          if (key == 13) {
              key = 8;
              keychar = String.fromCharCode(key);
          }
          return reg.test(keychar);
          
      }


Thanks.
Posted
Comments
Mohibur Rashid 23-Jun-15 20:19pm    
look at this link
vidkaat 24-Jun-15 10:33am    
Thanks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900