Disabling Auto-Correct And Auto-Capitalize Features On iPhone Inputs
2015-09-29 10:50
537 查看
Disabling Auto-Correct And Auto-Capitalize Features On iPhone Inputs
ByBen Nadel on January 5, 2012
Tags:
HTML / CSS
Over the weekend, I read
Mobile First by Luke Wroblewski. In his book, Wroblewski mentioned that in order to create the most usable experience on a mobile device, one should probably turn off the auto-correction and auto-capitalization features for input fields that don't require
them. This way, users don't have to worry about their email addresses being capitalized or their names being "corrected." I really loved this idea; but, Wroblewski didn't get into any code. After a bit of Googling, however, I found that both of these auto-input
features could be disabled with a simple HTML attribute.
Apple's "How-To" guide for coding Safari for iPhone. In it, there was a section that perfectly answered my question: "How do I disable automatic correction and automatic capitalization in text fields or text areas?" As it turns out, auto-correction
and auto-capitalization can be disabled with one HTML attribute (each):
autocorrect="off"
autocapitalize="off"
That seems simple enough. To experiment with this, I put together a quick demo and opened it up in my iPhone Simulator (which you can see in action in the above video):
<!DOCTYPE html>
<html>
<head>
<title>Disable Auto-Correct And Auto-Capitalization On iPhone</title>
<!---
Use the device width as the initial width of the
viewport. This way, we will have a zoom that is relevant
to our mobile app.
--->
<meta name="viewport" content="width = device-width" />
</head>
<body>
<h1 style="font-size: 16px ;">
Disable Input Field Auto-<br />
Features on iPhone
</h1>
<form>
<p>
Normal Input:<br />
<input type="text" style="width: 180px ;" />
</p>
<!--
On this in put, we will add the two "auto" attributes
to turn off auto-correct and auto-capitalization.
-->
<p>
No-Auto Input:<br />
<input
type="text"
autocapitalize="off"
autocorrect="off"
style="width: 180px ;"
/>
</p>
</form>
</body>
</html>
That's all there is to it! These features, combined with
using the right input type to trigger the right keyboard, should help keep the mobile experience as usable as the desktop experience.
相关文章推荐
- ajax传递的数据类型json传递
- jquery中eq()与get()的区别
- 更新包地址安装新版node.js
- Populating Next Right Pointers in Each Node 解答
- jquery中attr和prop的区别
- JSON字符串反序列化为MAP对象开发实例
- Jquery 全选/反选
- JS时间戳比较大小:对于一组时间戳(开始时间~结束时间)和另一组时间戳进行比较,用于判断被比较时间戳组是否在要求范围内
- Jquery中$.ajax()方法详解【转】
- 前端知识小积累
- JS属性的get和set方法
- JS 模态窗口
- IE浏览器下常见的CSS兼容问题
- js实现用户输入的小写字母自动转大写字母
- 写下常用的正则(regular expression)
- CSS-3 Animation 的使用
- canvas 追踪 js实现方案 实现浏览器唯一标示 标记
- js数组去重的4种方法
- jquery中attr和prop的区别
- jQuery对象原型构建-学习笔记