I need to create a form for a mobile website in which people can enter a number with a decimal mark like 5.3.
In order to make it easier for the visitors to enter the numbers, I want to force the smartphone to display the on-screen keyboard with the characters the user is most likely to enter.
It's possible to show the numbers on-screen keyboard by adding the HTML5 type="number"
input type.
Unfortunately Google Chrome then starts to validate the input and allows only intergers to be entered. So the user has a numbers on screen keyboard but cannot enter the number he needs to enter.
How can I display the numbers on-screen keyboard and still allow people who view the website with Google Chrome to enter numbers with decimal marks?
Create the field as follows:
This'll allow Chrome to validate correctly and not interfere. By default if you don't provide a step value it's 1, but it can be any positive floating value.
Tested in Chrome 10,12 with HTML5 and XHTML doctypes (both work). Example HTML: