javascript - Jquery preventDefault not working on android 4.4 default browser -
i working angular , jquery based website. have text input field validating array of floating numbers. requirement restrict user entering alphabets, etc.
the problem using e.preventdefault()
not working in android default browser working in android chrome.
i have searched lot unable solution.
my sample code :-
$('#test').keydown(function (e) { e.stoppropagation(); e.preventdefault(); e.returnvalue = false; e.cancelbubble = true; return false; });
i have tried :-
$('#test').keydown(function (e) { if (e.preventdefault) { e.preventdefault(); } else { e.returnvalue = false; } });
note:- cannot use keypress
event android default browser cannot listen event.
i had problem default browser on android. preventdefault didn't me, used .on jquery function.
$('#test').on('input',function () { var inputtext = $(this).val(); var resulttext = inputtext.replace(/[^0-9]/g, ''); $(this).val(resulttext); });
you can add regex other characters need allowed. hope helps.
Comments
Post a Comment