小编Ven*_*ran的帖子

event.preventDefault() 不适用于 android chrome

event.preventDefault() 不适用于 Chrome Android 操作系统。而同样的动作正在 chrome IOS 上工作。我什至使用了 event.stopPropagation()、event.stopImmediatePropagation()。

HTML:

 <input class="otherAmount" type="text"id="pVal" name="pVal" onkeydown="validatePaymentToTwoDecimal(this,event);"/>         
Run Code Online (Sandbox Code Playgroud)

Java脚本:

function validatePaymentToTwoDecimal(el, evt) {

        if(!$.isNumeric(evt.key)|| evt.key=="."){
            evt.preventDefault();
            evt.stopPropagation();
            evt.stopImmediatePropagation();
            return false;
        } else {
              return true;
        }
}
Run Code Online (Sandbox Code Playgroud)

javascript

5
推荐指数
1
解决办法
7775
查看次数

标签 统计

javascript ×1