S
S
spiridonov12016-01-04 21:11:04
JavaScript
spiridonov1, 2016-01-04 21:11:04

Is there an alternative to input type="number" to show a number pad on a smartphone?

The fact is that browsers begin to process input in a field with type = "number" in a special way. And if special browser styles can somehow be disabled:

/* Удаляем стрекли для ячеек с type number в Chrome. */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
/* Удаляем стрекли для ячеек с type number в Firefox. */
input[type="number"] {
    -moz-appearance: textfield;
}
/* Удаляем красную рамку для ячеек с type number в Firefox. */
input:invalid {
    box-shadow: none;
}

How to disable browser validation? For example, the browser does not take into account text input into such cells.
https://jsfiddle.net/oxy2ja2t/
And I need to know the user's input, even if it's not just numbers. But I can't do it. The same problem occurs when entering a decimal point "," instead of a decimal point "." the browser thinks it's text.
https://jsfiddle.net/fm7ap1vz/
As a result, the solution with type="number" needed only to show the numeric keypad on a smartphone carries a lot of problems. Please tell me an alternative way to show the numeric keypad on a smartphone or how can I remove browser validation. Thanks a lot.
PS It would be possible to use type="tel", but I need a decimal point when entering from a smartphone, and with type="

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
trushka, 2016-01-04
@trushka

You can define mobile devices by user agent and set type="number" for them. It can be on the server, it can be javascript..

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question