WAP网页输入框的默认键盘类型控制
来源:互联网 发布:10年决赛科比数据 编辑:程序博客网 时间:2024/04/23 15:48
最近有用户反映手机网的输入框不够人性化,比如手机号、卡号输入框应该默认显示数字键盘,邮箱输入框应该默认显示邮箱键盘。
百度上对这样的资料介绍很多,基本上都和这个页面是一个意思 http://www.w3school.com.cn/html5/att_input_type.asp :
语法
<input type="value">
属性值
但是不能满足我的需求,在安卓下正常,但是在iPhone下就不行了。比如如果是卡号的话,按照这里所说,应该用type=”number”,但是我们卡号是0打头,这种情况下会输入框失去焦点时,自动删除开头的0。后来谷歌到一个外国网站有讲。http://sja.co.uk/2012/1/4/controlling-which-ios-keyboard-is-shown
Controlling which iOS keyboard is shown →
Note: This is a minor update to a post I made last year, migrated from a previous blog.
One of my pet hates (there are many), is being presented with the incorrect keyboard, or having auto capitalisation forced upon me, when entering information into web forms on my iPhone or iPad. This is something that’s very easy to control and can be done so with a little sprinkle of HTML5. You don’t even have to worry about old browsers – I’ve tested this to work perfectly well even in IE6.
The screenshots used in this post are from a UK based iPhone 4S running iOS5; previous versions of iPhone OS and the iPad will differ.
Text keyboard
Your standard text input field code will look something like this:
<input type="text"></input>
Telephone keyboard
In order to display the telephone keyboard, use this:
<input type="tel"></input>
URL keyboard
For URLs you want this:
<input type="url"></input>
Email keyboard
For email addresses, you want this:
<input type="email"></input>
Numerical keyboard
And finally, for a simple numerical keyboard (similar to the telephone one but with no +, * and # key):
<input type="text" pattern="[0-9]*"></input>
Other options
It’s also possible to control auto correct with the use of the following paramater:
autocorrect="off"
Last, but by no means least, turning on or off auto capitalisation:
autocapitalize="off"
So the next time you’re creating a login field that takes an email address, use something like this:
<input type="email" autocorrect="off" autocapitalize="off"></input>
至于在安卓和苹果上的区分,可以采用php来判断用户当前的操作系统,然后分别给出不一样的输入框,函数如下:
//判断用户的客户端类型
function clientType(){
if(stristr($_SERVER['HTTP_USER_AGENT'],’Android’)) {
return “android”;
}else if(stristr($_SERVER['HTTP_USER_AGENT'],’iPhone’)){
return “ios”;
}else{
return “other”;
}
}
- WAP网页输入框的默认键盘类型控制
- WAP网页输入框的默认键盘类型控制
- 手机网页(WAP)页面上的输入框默认键盘类型
- 如何控制WAP网站上输入框的默认键盘类型
- 控制键盘的输入
- 控制弹出键盘的类型
- 屏蔽所有键盘控制网页的键
- 控制文本框输入的类型
- javascript keyCode总结,控制键盘的输入
- wap开发中输入框不能输入内容的解决方案
- 改变手机浏览器(iPhone/Android)上文本输入框的默认弹出键盘(数字)
- iOS5网页视图(UIWebView)中的输入框不能弹出键盘的问题
- input键盘控制输入值
- 用键盘控制光标在输入框中跳转的小巧门
- 用键盘控制光标在输入框中跳转的小巧门
- 控制键盘在input输入为数字的JS
- Android 动态限制EditText输入的字条类型及键盘类型、对输入的监控
- 控制输入法显示合适的键盘类型(android:inputType)
- 微信公众平台开发(51)会员卡
- 一键生成HTML4和WAP站
- 腾讯推出微信企业服务平台风铃
- 腾讯风铃
- 如何通过微信创业赚钱
- WAP网页输入框的默认键盘类型控制
- 淘宝微信互相屏蔽影响了谁
- 微信公众平台2013.08.05更新说明
- 微信5.0安卓内测版下载
- 微信公众平台高级功能
- 微信公众平台开发(52)大转盘
- 微信公众平台开发(53)砸金蛋
- 微信公众平台开发(54)翻板抽奖
- 微信公众平台开发(55)刮刮乐