简体   繁体   中英

Sencha ExtJs TextField KeyDown Event in FireFox

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

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;
                                }
                            }
                        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM