Use mobile web form numbers

I have a simple web form designed for Opera Mini and Opera Mobile. I use only the HTML input element.

Now I would like to limit the element to integers only. Is there a way to ensure this in this browser (perhaps even if the phone will turn on the number mode when entering the form)?

And if I wanted to enable float, is something possible?

+3
source share
3 answers

You should be able to use the input type "number", this is part of the HTML5 specification. I'm not sure Opera will automatically display the numeric keypad, but iphone at least will ...

+1

XHTML Basic inputmode="digits" <input>, . HTML5.

+1
<input type='tel' /> 

A numeric keypad will appear on Android, WP8 and iPhone by default, as well as Chrome for Android. In my Android browsers, non-numeric characters are deleted.

<input type='number' /> 

should work great for floats. In both Android browsers, it also automatically removes the leading zeros of onblur.

+1
source

Source: https://habr.com/ru/post/1732396/


All Articles