The 'filter' function defines how to filter the key pressed, return true to accept the inputed char.
$('#n1').numberbox({
filter: function(e){
var opts = $(this).numberbox('options');
var s = $(this).numberbox('getText');
if (e.metaKey || e.ctrlKey){
return true;
}
if ($.inArray(String(e.which), ['46','8','13','0']) >= 0){ // DELETE BACKSPACE ENTER
return true;
}
var tmp = $('<span></span>');
tmp.html(String.fromCharCode(e.which));
var c = tmp.text();
tmp.remove();
if (!c){
return true;
}
if (c == '-' || c == opts.decimalSeparator){
return (s.indexOf(c) == -1) ? true : false;
} else if (c == opts.groupSeparator){
return true;
} else if ('0123456789'.indexOf(c) >= 0){
return true;
} else {
return false;
}
}
})