Tuesday, July 7th, 2020

Allow Numbers/Digits in textbox in javascript


Allow Numbers/Digits in textbox  in javascript
<SCRIPT language=Javascript>
function isNumberKey(evt)
var unicode=e.charCode? e.charCode : e.keyCode
if (unicode!=8){
if (unicode<48||unicode>57)
return false;}

return true;
<INPUT id=”txtChar” onkeypress=”return isNumberKey(event)” type=”text” name=”txtChar”>
Here this above coding shows to use Javascript to allow only numbers to be entered in a textbox. This is useful for phone numbers, IDs, ZipCodes.

This solution works in both IE and Netscape/Mozilla.

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • RSS
  • Technorati
  • Twitter

Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!

Secure Linux Web Hosting