I have a simple webform targeted for Opera Mini and Opera Mobile. I'm using just a HTML input element.
Now I would like to restrict the element to 开发者_如何学Goonly have integer numbers. Is there a way to enforce this in this browser (possible even that the phone will have it's number mode on when entering the form)?
And if I wanted to allow floats, is something possible then?
You should be able to use the "number" input type, it's part of the HTML5 spec. I'm unsure if Opera will automatically display the numeric keypad but the iphone at least does...
In XHTML Basic, you can use inputmode="digits"
on your <input>
tags to accomplish this. It ought to be more widely supported on mobile browsers that HTML5 mechanisms.
<input type='tel' />
will bring up a numeric keypad on Android, WP8, and iPhone default browsers as well as Chrome for Android. On my Android browsers, non-numeric characters are stripped onblur.
<input type='number' />
should work fine for floats. On both of my Android browsers, it also automatically removes leading zeros onblur.
精彩评论