【问题标题】:ASCII code not working in firefox but on chrome working fineASCII 码不能在 Firefox 中工作,但在 chrome 上工作正常
【发布时间】:2017-07-03 16:24:19
【问题描述】:

我创建了允许在 chrome 上输入所有字符和几乎所有符号的功能,并且工作正常,但在 Firefox 上我无法输入任何字符或任何符号

下面是我的脚本

  function blockSpecialChar(e) {
    var k = e.keyCode;
    return ((k > 64 && k < 91) || (k > 96 && k < 123) || (k > 31 && k < 34) || (k > 34 && k < 38) || k == 8 || k == 64 || k == 95 || k == 61 || k == 63 || (k > 39 && k <= 57));
}

.aspx 代码

<asp:TextBox ID="txtdescribe"  onkeypress="return blockSpecialChar(event)" CssClass="input" ValidationGroup="services" runat="server" MaxLength="255"></asp:TextBox>

此功能仅限制插入 html 符号,但在 firefox 上也不允许插入字符

chrome 示例

Firefox 示例

【问题讨论】:

  • 我认为您需要提供更多信息。这很模糊。目前尚不清楚究竟是什么不起作用。显示示例输入、预期输出和实际输出。
  • 信息正常吗?
  • 我认为这个问题与功能无关。你是如何使用这个功能的?
  • @Carcigenicate on key press 我正在使用该功能

标签: javascript jquery google-chrome firefox ascii


【解决方案1】:

试试这个:

function blockSpecialChar(e) {    
        if (e == 60 || e == 62 || e == 34 || e == 38 || e == 39) {
            return false;
        }
        else {
            return true;
        }    
}

onClick="ToggelDiv(this.id); Specialinstruction();"

这些将适用于所有浏览器。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-07-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多