keypress/keyup is not working on chrome mobile browser

隐身守侯 提交于 2019-12-14 02:16:04

问题


I have been using jquery in my web based Asp.net MVC application, and when i use chrome mobile to test my work i found that jquery's functions which are based upon keypress/keyup is not working.

I didn't know why it is not working on mobile browsers. It is working properly on desktop browsers.

Can anyone solve my problem, thanks in advance.


回答1:


This worked for me: http://www.dotnetfunda.com/forums/show/8137/onkeyup-event-not-firing-in-firefox-and-chrome

The code:

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

} 

}



来源:https://stackoverflow.com/questions/48668105/keypress-keyup-is-not-working-on-chrome-mobile-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!