开发者

Only numbers as keyboard input for ipad

I have to display a number pad as keyboard for a开发者_如何学运维 textfield (it can take only numerals) in case of ipad.setting keyboard type as UIKeyboardTypeNumberPad displays numeric keyboard but user can switch back to alphabets.Is there any keyboard for ipad that just displays numbers?


Use the input type "number"

<input type="number" />

or failing that use a validation pattern which only accepts numbers.

<input type="text" pattern="[0-9]*" />

Both of these should bring up the num pad on iPhones and bring up the iPad keyboard with the numbers exposed (amongst the other keys)


You would have to create your own keyboard to accomplish this.


You could get calculator app with open source code and use their keypad code, or do what I did. Made my own by coding the buttons you want and displaying them how you want eg in a square like a calculator. By using on click event to update a numeric variable. Eg multiply the last entered integer by 10 and add the new integer supplied by the on click code. Ie press button 2 and var = 2. Press another 2 and the var is multiplied by 10 and new var is added , to give 22 . Etc

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜