I am working with a angular and jquery based website. I have a text input field for validating array of floating numbers. My requirement is to restrict the user from entering alphabets, etc.
The problem is I am using e.preventDefault()
but its not working in android default browser but working perfectly in android chrome.
I have searched a lot but unable to get any solution.
My sample code :-
$('#test').keydown(function (e) {
e.stopPropagation();
e.preventDefault();
e.returnValue = false;
e.cancelBubble = true;
return false;
});
I have also tried :-
$('#test').keydown(function (e) {
if (e.preventDefault) {
e.preventDefault();
} else {
e.returnValue = false;
}
});
Working fiddle
Note:- I cannot use keypress
event as the android default browser cannot listen this event.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…