I am seeing strange behavior by Javascript on Android devices. I want an HTML textbox that behaves very like a password field - the characters are obscured as the user types. I have reduced the code to a single line. Works fine on my PC, on iPhone, and on iPad. But not my Moto phone or Samsung tablet, both of which are running Android.
<input type='text' ID='txtPseudoPassword' name='txtPseudoPassword' onkeydown = 'if (event.keyCode != 8 && event.keyCode != 46) { document.getElementById("txtPseudoPassword").value += "#"; return false; } else return true; ' >
I have tried using event.preventDefault();
as well as return false;
but it makes no difference. I have tried onkeypress instead of onkeydown, but similarly, the devices that already work continue to do so and the Android devices don't.
So if I type 'ABC' into an iPad, I see '###'. If I type it into either of the Android devices at my disposal, I get '#A#AB#ABC'.
Another example might be helpful (at least in ruling out 'use a password field'). Take this line
<input type='text' ID='txtPseudoPassword' name='txtPseudoPassword' onkeydown = 'if (event.keyCode != 8 && event.keyCode != 46) { document.getElementById("txtPseudoPassword").value += String.fromCharCode(event.keyCode) + String.fromCharCode(event.keyCode) ; return false; } else return true; ' >
On non-Android, it doubles any character entered. On Android, well .. try it and see