WAP网页输入框的默认键盘类型控制
最近有用户反映手机网的输入框不够人性化,比如手机号、卡号输入框应该默认显示数字键盘,邮箱输入框应该默认显示邮箱键盘。
百度上对这样的资料介绍很多,基本上都和这个页面是一个意思 http://www.w3school.com.cn/html5/att_input_type.asp :
语法
<input type="value">
属性值
| 值 | 描述 |
|---|---|
| button | 定义可点击的按钮(大多与 JavaScript 使用来启动脚本) |
| checkbox | 定义复选框。 |
| color | 定义拾色器。 |
| date | 定义日期字段(带有 calendar 控件) |
| datetime | 定义日期字段(带有 calendar 和 time 控件) |
| datetime-local | 定义日期字段(带有 calendar 和 time 控件) |
| month | 定义日期字段的月(带有 calendar 控件) |
| week | 定义日期字段的周(带有 calendar 控件) |
| time | 定义日期字段的时、分、秒(带有 time 控件) |
| 定义用于 e-mail 地址的文本字段 | |
| file | 定义输入字段和 “浏览…” 按钮,供文件上传 |
| hidden | 定义隐藏输入字段 |
| image | 定义图像作为提交按钮 |
| number | 定义带有 spinner 控件的数字字段 |
| password | 定义密码字段。字段中的字符会被遮蔽。 |
| radio | 定义单选按钮。 |
| range | 定义带有 slider 控件的数字字段。 |
| reset | 定义重置按钮。重置按钮会将所有表单字段重置为初始值。 |
| search | 定义用于搜索的文本字段。 |
| submit | 定义提交按钮。提交按钮向服务器发送数据。 |
| tel | 定义用于电话号码的文本字段。 |
| text | 默认。定义单行输入字段,用户可在其中输入文本。默认是 20 个字符。 |
| url | 定义用于 URL 的文本字段。 |
但是不能满足我的需求,在安卓下正常,但是在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网页输入框的默认键盘类型控制的更多相关文章
- WEB网页输入框的默认键盘类型控制
参考资料 http://www.w3school.com.cn/html5/att_input_type.asp : 语法 <input type="value"> 属 ...
- 如何控制WAP网站上输入框的默认键盘类型
百度上对这样的资料介绍很多,基本上都和这个页面是一个意思 http://www.w3school.com.cn/html5/att_input_type.asp : 语法 <input type ...
- EditText ------- 键盘类型
文本输入框指定软键盘类型和软键盘回车键图标设置, 转载:http://blog.csdn.net/wirelessqa/article/details/8567327
- 控制 WAP 网站上输入框的默认类型
比如手机号,卡输入框应该默认显示数字键盘,邮箱输入框应该默认显示邮箱键盘.www . c s d n 1 2 3 . com/html/itweb/20130802/36036_36043_36004 ...
- 改变手机浏览器(iPhone/Android)上文本输入框的默认弹出键盘
iPhone/iPad和Android提供不同的的键盘输入类型,触发合适的键盘将极大地改善用户体验. 键盘类型 默认: 默认键盘的字母模式 数字: 默认键盘的数字模式,(含小数点等) 邮件: 与默 ...
- [转载]Js小技巧||给input type=“password”的输入框赋默认值
http://www.cnblogs.com/Raywang80s/archive/2012/12/06/2804459.html [转载]Js小技巧||给input type="passw ...
- iOS 键盘类型定制归纳
一.键盘风格 支持8种风格键盘. typedef enum { UIKeyboardTypeDefault, // 默认键盘:支持所有字符 UIKeyboardTypeASCIICapable, // ...
- 与众不同 windows phone (24) - Input(输入)之软键盘类型, XNA 方式启动软键盘, UIElement 的 Touch 相关事件, 触摸涂鸦
原文:与众不同 windows phone (24) - Input(输入)之软键盘类型, XNA 方式启动软键盘, UIElement 的 Touch 相关事件, 触摸涂鸦 [索引页][源码下载] ...
- 手机浏览器wap网页点击链接触发颜色区块的问题解决办法
引子 在做HTML5 WAP网页的时候,一行内容做了2个链接,点击一个标签的时候,整个颜色块会闪一下,影响美观.需求针对这种情况来问我,能否把这个一闪的颜色去掉.我当时就想,这个怎么去?那我也不好直接 ...
随机推荐
- shell的执行顺序问题
&&,||,(),{},& 五个符号的运用 shell脚本执行命令的时候,有时候会依赖于前一个命令是否执行成功.而&&和||就是用来判断前一个命令执行效果的. ...
- C# CryptoStream
using System; using System.IO; using System.Security.Cryptography; namespace RijndaelManaged_Example ...
- 编译过程中,termcap.h 文件找不到路径 licli.a终于生成
编译过程中,termcap.h 文件找不到路径 查看是linux 源码下找不到termcap.h文件 安装了所有关于*cap*的源码包也不起作用 今天终于解决了这个问题,搜 ...
- 编译安装apache-2.4.18
apache安装时, 必须要apr和apr-util, 这两个包是必须的 当下载apache的版本过高, 如: apache-2.4.18, 那么要求的apr或apu=apr-util版本将至少在1. ...
- Linux for windows cp 数据中文乱码
今天遇到一个很奇葩的问题,不仅让我纠结了半天更影响了我的工作效率找到了一种解决方法.分享和记录下以备自己和后人参考 说下情况 本人的Linux服务器上的数据要cp到新安装的windows server ...
- Java主流日志工具库
在项目开发中,为了跟踪代码的运行情况,常常要使用日志来记录信息.在Java世界,有很多的日志工具库来实现日志功能,避免了我们重复造轮子.我们先来逐一了解一下主流日志工具. 1.java.util.lo ...
- 百科编辑器ueditor应用笔记
最近项目上要用到文本编辑器,选了百科开源的ueditor,使用过程中虽然有些问题,但是一个个都解决了,记录如下: 开发的项目环境是vs2012:.net4.0: 1:百度js编辑器,编辑器加载到项目中 ...
- 登录DA面板出现:License has expired
登录DA面板出现:License has expired的解决方法. 首先看是否过期,如果出现The license looks fine on this end. 登录 SSH as root # ...
- 微信智慧KTV上线 不怕周末订不到包厢了
周末邀三五好友唱唱歌是件惬意的事,可订包厢是个烦心事,总是people mountain people sea,而且价格比平时高出不少.现在好了,微信智慧KTV上线了,将有效解决传统KTV收银时间集中 ...
- HDU 3998 Sequence(经典问题,最长上升子序列)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3998 解题报告:求一个数列的最长上升子序列,并求像这样长的不相交的子序列最多有多少个. 我用的是最简单 ...