//use: $("selector").inputOnlyNum();只输入数字
(function($) {
$.fn.inputOnlyNum = function() {
this.keypress(function(e) {
if (e.which == 8 || e.keyCode == 9) return true; //Backspace & Tab in ff
var b = /^[\d\.-]$/.test(String.fromCharCode(e.which));
if (b) {
window.setTimeout(function() {
if (isNaN($(e.target).val()) && $(e.target).val() != '-') { $(e.target).val(''); }
}, 10);
}
return b;
}).bind("paste", function() { return !isNaN(clipboardData.getData('text')); })
.bind("dragenter", function() { return false; }).css("ime-mode", "disabled");
};
})(jQuery);