How to allow only numbers(digits) to input

This is javascript function that doesn’t permits to input characters others than number:


function inputOnlyNumbers(evt){
var e = window.event || evt; // for trans-browser compatibility
var charCode = e.which || e.keyCode;
if ((charCode > 47 && charCode < 58) || charCode == 8){
return true;
}
return false;

}

And this is how to call it example html snippet:



    
...

...
   

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • MySpace
  • RSS
  • Twitter
  • Yahoo! Bookmarks
  • Yahoo! Buzz
  • BlinkList
  • blogmarks
  • DZone
  • E-mail this story to a friend!
  • LinkaGoGo
  • Live
  • MisterWong
  • MisterWong.DE
  • Reddit
  • StumbleUpon
  • Technorati
  • ThisNext
  • Tumblr

No related posts.

Leave a Reply


wordpress seo