E
E
Evgeny2018-07-05 12:27:59
JavaScript
Evgeny, 2018-07-05 12:27:59

How to solve the problem with the input mask on the phone?

Friends, hello everyone!

There is a site altayekoprodukt-opt.ru , to which the maskedinput.js phone input mask is connected.

5b3dea1fcaa7b552420042.jpeg
The form appears when you click on the "I want a price, call me" button, etc.

In desktop browsers and mobile FF, everything is fine, but in mobile Chrome and Opera, numbers are not entered in the mask, and underscores are substituted instead of the entered characters.

I can't do it myself, I need help.

What could be the problem?

Thanks in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Kudis, 2018-07-05
Myagkikh @myagkikh_evgeniy

The first thing to do is to specify the type 'tel' for this field (you have 'text'), then the keyboard on mobile phones will also be numeric.
There is a chance that this will fix the situation.
If not, then use jQuery's inputmask plugin

$(function () {
   $(".js-form__input--tel").inputmask("mask", {"mask": "+7 (999) 999-9999"});
});

if you want the format to be "Russian mobile" +7(9xx)xxx-xxxx (where x is any number)
then jQuery inputmask will allow you to make a mask like this:
$(function () {
    $('.js-form__input--tel').inputmask({
        mask: "+7 (X99) 999-9999",
        definitions: {
            'X': {
                validator: "9",
                placeholder: "9"
            }
        }
    });
});

you also have this madness in your script:
var z;
    (z = $(".js-form__input--tel")).on("keydown", function (t) {
        var a = t.keyCode;
        if ("+7 (___) ___-____" === z.val() && (104 === a || 103 === a || 55 === a || 56 === a)) return !1
    });

I don't know what it does, but it seems to be something bad)))))

A
Alexander Seryakov, 2018-07-05
@alexndb

There is a suspicion that this is due to loading scripts at the time of window.onload, try replacing this with $(document).ready(function () {
$(".js-form__input--tel").mask("+7 ( 999) 999-9999")
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question