【问题标题】:keypress/keyup is not working on chrome mobile browserkeypress/keyup 在 chrome 移动浏览器上不起作用
【发布时间】:2018-07-17 23:55:43
【问题描述】:

我一直在基于 Web 的 Asp.net MVC 应用程序中使用 jquery,当我使用 chrome mobile 测试我的工作时,我发现基于 keypress/keyup 的 jquery 功能不起作用。

我不知道为什么它不能在移动浏览器上运行。它在桌面浏览器上正常运行。

谁能解决我的问题,在此先感谢。

【问题讨论】:

标签: javascript jquery asp.net-mvc validation mobile-browser


【解决方案1】:

这对我有用: http://www.dotnetfunda.com/forums/show/8137/onkeyup-event-not-firing-in-firefox-and-chrome

代码:

<textarea name="textarea" id="txtComments" rows="3" onkeyup='return fnMaxLength(this,"5");' style="width: 940px" ></textarea> 

function fnMaxLength(field, maxChars) {

if (field.value.length >= maxChars) { 

    var object = "-More than " + maxChars + " characters have been entered.";

    //errorAlert("error", "Maximum length error", object);

    alert(object);

    return false; 

} 

}

【讨论】:

    猜你喜欢
    • 2018-01-08
    • 1970-01-01
    • 2021-12-23
    • 2019-08-07
    • 1970-01-01
    • 2012-05-23
    • 1970-01-01
    • 2021-11-13
    相关资源
    最近更新 更多