views:

181

answers:

4

I need to make a textbox that only allows numeric characters. I've looked through several numeric plugins and can't find one that I like. I'm looking for either a plugin recommendation with the associated URL or syntax showing how to get started on making my own plugin.

+2  A: 

You may take a look at this plugin.

Darin Dimitrov
+1  A: 

The masked input plugin should do exactly what you need.

Matt Ball
A: 

You can start by implementing the function with JQuery and then integrate it into a (configurable) plugin.

To handle textbox input you should intercept keydown event on textbox and then prevent the input if it's not allowed.

To write a plugin you can start from here: http://www.learningjquery.com/2007/10/a-plugin-development-pattern http://www.learningjquery.com/2009/03/making-a-jquery-plugin-truly-customizable

mamoo
+1  A: 
$("#testinput").keypress(function(e){
  if (isNaN(String.fromCharCode(e.which))){
    return false;
  }
});
Jon