Hello, I'm struggling with this too!
On keypress I want a certain key '#' to be able to fill the field with a hash, even though it is a numberbox.
I have an icon that does the same thing, this works fine.
I can't however get the keypress event to set the hash. When the field loses focus the hash is removed from its value.
My code:
var $yr = $('form#myform input.Year');
if ($yr.length) {
$yr.numberbox({
icons: [
{
iconCls: 'icon-hash',
handler: function (e) {
//this works fine
$(e.data.target).textbox('setValue', '#');
}
}
],
inputEvents: $.extend({}, $.fn.numberbox.defaults.inputEvents, {
keypress: function (e) {
var result = $.fn.numberbox.defaults.inputEvents.keypress.call(this, e);
if (e.keyCode == 35) {
//this doesn't work
$(e.data.target).textbox('setValue', '#');
}
return result;
}
})
});
}
Can you help?