Reputation: 587
So I have the following code that detects where the key that was pressed is a number, space or delete key. If not it stops the key from being entered into the textfield. It works perfectly in Chrome and IE. When I run it in FireFox I get the following error: returnValue is undefined in the following statement: e.event.returnValue = false;
Here is the code:
keydown:function( sender, e, eOpts )
{
if (!isNumberKey(e))
{
e.event.returnValue = false;
}
}
The Function that does the work:
function isNumberKey(e)
{
//Local Varaible Declaration
var returnValue = false;
if (e.keyCode >= 96 && e.keyCode <= 105)
{
returnValue = true;
}
else if (e.keyCode >= 48 && e.keyCode <= 57)
{
returnValue = true;
}
else if (e.keyCode == 8 || e.keyCode == 46)
{
returnValue = true;
}
return returnValue;
}
I looked in the debugger in the firefox and found that returnValue really is not there. What do I use instead? I am sure there must be a way to accomplish this in FireFox.
Thanks,
Josh
Upvotes: 1
Views: 2175
Reputation: 587
It took me like 4 hours but here is the solution. Hope this helps:
keydown:function( sender, e, eOpts )
{
if (!isNumberKey(e))
{
if (Ext.browser.is.Firefox)
{
e.event.preventDefault();
}
else
{
e.event.returnValue = false;
}
}
}
Upvotes: 3