【问题标题】:unable to navigate back using arrow keys input text box无法使用箭头键输入文本框向后导航
【发布时间】:2014-01-24 05:29:03
【问题描述】:

我有一个使用以下 jquery 事件限制特殊字符的输入文本框

$(":input").bind("keyup blur", function(){
    $(this).val( $(this).val().replace(/[^a-zA-Z\s]/g,'') );
});

现在,问题是,在用一些数据填充字段后,我无法使用箭头键导航回来。在 chrome 和 ie 中可以看到这种限制。在Firefox中它很好。我需要你的帮助。

谢谢

【问题讨论】:

    标签: jquery textfield


    【解决方案1】:

    这对我来说很好用。试试这个,这可能会有所帮助!

    $("[id$='']").keyup(function () {

          if (this.value.match(/[^a-zA-Z0-9 ]/g)) 
             {
                    this.value = this.value.replace(/[^a-zA-Z0-9 ]/g, '');
                    return;
             }              
    

    });

    【讨论】:

      【解决方案2】:

      最后,这对我有用

          $(":input").bind("keyup blur", function(){
              if(e.keyCode != 37 && e.keyCode != 39) {
              $(this).val( $(this).val().replace(/[^a-zA-Z\s]/g,'') );
              }
          });
      

      【讨论】:

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