php网站输入框安全键盘代码,WEB网页输入框的默认键盘类型控制

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

iphone-keyboard-text.png

Your standard text input field code will look something like this:

Telephone keyboard

iphone-keyboard-tel.png

In order to display the telephone keyboard, use this:

URL keyboard

iphone-keyboard-web.png

For URLs you want this:

Email keyboard

iphone-keyboard-email.png

For email addresses, you want this:

Numerical keyboard

iphone-keyboard-numerical.png

And finally, for a simple numerical keyboard (similar to the telephone one but with no +, * and # key):

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:

至于在安卓和苹果上的区分,可以采用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”;

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值