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.
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
2010-04-08 14:01:25
+1
A:
$("#testinput").keypress(function(e){
if (isNaN(String.fromCharCode(e.which))){
return false;
}
});
Jon
2010-04-08 14:22:15