2010年10月29日金曜日

テキストボックスのオートコンプリートを無効にするHTML

ブラウザのテキストボックスをトリプルクリック(Firefoxや昔のIEではダブルクリック)したり、↓キーを押すと、以前にそのテキストボックスに入力した値を表示してくれる便利機能の「オートコンプリート」。
でも個人情報なんかの関係で、見せたくない場合もある。

そんな時にはautocomplete="off"を付ければオートコンプリート機能は無効になる。
<input type="text" name="foo" autocomplete="off" />

多くのブラウザが既に対応している。それに追随する形で、HTML5で正式に採用されたみたい。

4.10.7.2 Common input element attributes — HTML5 (Edition for Web Authors)
The autocomplete attribute is an enumerated attribute. The attribute has three states. The on keyword maps to the on state, and the off keyword maps to the off state. The attribute may also be omitted. The missing value default is the default state.

0 件のコメント:

ブログ アーカイブ

カテゴリー