event.preventDefault()がChromeのAndroid OSで動作していません。同じアクションがChromeのIOSで動作しています。 私はevent.stopPropagation()、event.stopImmediatePropagation()も使用しました。event.preventDefault()がAndroidのChrome OSで動作しない
HTML:
<input class="otherAmount" type="text"id="pVal" name="pVal" onkeydown="validatePaymentToTwoDecimal(this,event);"/>
Javaスクリプト:
function validatePaymentToTwoDecimal(el, evt) {
if(!$.isNumeric(evt.key)|| evt.key=="."){
evt.preventDefault();
evt.stopPropagation();
evt.stopImmediatePropagation();
return false;
} else {
return true;
}
}
どのような種類のイベントを処理していますか? –
keydown.Though onKeyDownがfalseを返しても、私はhtmlフィールドのキー値を参照してください。 最初はKeypressを使ってみました。 KeypressはAndroid上で動作せず、IOS上で動作します。だからkeydownに移動 –
あなたのコードはどこですか? –