在Firefox中使用JavaScript捕获标签键 [英] Capturing the tab key using JavaScript in Firefox

查看:109
本文介绍了在Firefox中使用JavaScript捕获标签键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下内容限制用户只输入一些字符。
当我按Tab时,光标不指向下一个控件(在Mozilla中)。但它在IE中正常工作。

I use the following to restricts user to enter only some characters. When I press tab, the cursor does not point to next control (in Mozilla). But it works fine in IE.

// Restricts user to enter characters other than a to z, A to Z and white space( )
// Rauf K. 06.11.2010
$("input:text.characters_only").keypress(function(e) {
if (!((e.which >= 65 && e.which <= 90) || (e.which >= 97 && e.which <= 122) || e.which == 32 || e.which == 8 || e.which == 9)) {
        return false;
    }
});


推荐答案

我建议尝试 e .keyCode 而不是 e.which 。这是一个SO链接,它描述了一个很好的方法,可以将键击到单个变量: jQuery事件键:按下哪个键?

I would recommend trying e.keyCode instead of e.which. Here is a SO link that describes a good method of getting the key strike into a single variable regardless: jQuery Event Keypress: Which key was pressed?

这篇关于在Firefox中使用JavaScript捕获标签键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆