mobile – Prevent characters from entering the field.


Good day.
There is such a problem on some phones (for example sony):

Let's take a field

<input type="tel" value="+7 (---) --- -- --" id="inputField-ms" name="ms">

Let's forbid him to enter with the following instruction:

var ifmc = document.getElementById("inputField-ms");

ifmc.onkeydown = function () {
    return false;

As it should be, everything works as it should in the browser and on the Galaxy S3. But when I take another phone, weaker, for example. Sony or Huawei, then when you enter, for a moment the entered character jumps out in the input field, then disappears. This issue occurs on Android 4.0.3. It's okay on the iPhone.

How can I get rid of this behavior so that the entered character does not appear for a moment on any phones?

Of course, I need a more complicated operation – I need to keep track of what the user enters into the field, but so that the character entered is not displayed, but that's me.


Make a transparent margin over the main margin. Enter letters into the transparent field, check. If everything is ok, then add the symbol to the main field.

Scroll to Top