3キャリアでの入力モード指定
通常はフォームのテキストとかの入力欄は日本語が初期状態になっている。
これを初めから半角英数字モードにする方法。
キャリアによって、さらにhtmlかxhtmlかによってモードの指定方法が異なるのでメモ。
・html
inputタグの中に指定する。
<input type="text" name="hoge" istyle="1" format="*M" mode="hiragana" />
・xhtml
inputタグのstyleの中に指定する。
<input type="text" name="hoge" style="-wap-input-format:"*<ja:h>";-wap-input-format:*M;" />
■docomo ・html 全角(デフォルト): istyle = 1 半角カナ : istyle = 2 英字 : istyle = 3 数字 : istyle = 4 ・xhtml 全角(デフォルト): style="-wap-input-format:"*<ja:h>"" 半角カナ : style="-wap-input-format:"*<ja:hk>"" 英字 : style="-wap-input-format:"*<ja:en>"" 数字 : style="-wap-input-format:"*<ja:n>"" ※docomoではstyleの中に<>などの記号を使う場合、エスケープする必要がある
■au ・html 全角(デフォルト): format="*M" 英字 : format="*m" 数字 : format="*N" ・xhtml 全角(デフォルト): style="-wap-input-format:*M;" 英字 : style="-wap-input-format:*m;" 数字 : style="-wap-input-format:*N;" ※auは半角カナモードが指定できない ※「*」を数字にすると、文字数制限も可能
■SoftBank ・html 全角(デフォルト): mode="hiragana" 半角カナ : mode="hankakukana" 英字 : mode="alphabet" 数字 : mode="numeric" ・xhtml 全角(デフォルト): style="-wap-input-format:'*<ja:h>" 半角カナ : style="-wap-input-format:'*<ja:hk>" 英字 : style="-wap-input-format:'*<ja:en>" 数字 : style="-wap-input-format:'*<ja:n>"
機種によっては、初期入力モードだけが変更されるものと、
入力モードが固定されて変更できないものがあるので注意が必要。
・疑問点
xhtmlで実装してみたら、docomoだけ入力モードが変更されなかった。
で、style="-wap-input-format:"*<ja:h>""のエスケープ処理を外したら (Softbankと同じstyle="-wap-input-format:'*
きちんと入力モードの指定が出来た。原因がよく分からない。。
で、それも踏まえて3キャリア対応した入力モード指定のタグ
・全角(デフォルト) <input type="text" name="hoge" istyle="1" format="*M" mode="hiragana" style="-wap-input-format:'*<ja:h>;-wap-input-format:*M;" /> ・半角カナ <input type="text" name="hoge" istyle="2" format="*M" mode="hankakukana" style="-wap-input-format:'*<ja:hk>;-wap-input-format:*M;" /> ・英字 <input type="text" name="hoge" istyle="3" format="*m" mode="alphabet" style="-wap-input-format:'*<ja:en>;-wap-input-format:*m;" /> ・数字 <input type="text" name="hoge" istyle="4" format="*N" mode="numeric" style="-wap-input-format:'*<ja:n>;-wap-input-format:*N;" />
それにしても、
mode="hiragana"、mode="hankakukana"
なんかダサい。。
■追記
なぜかauのw61tのみ、上記で入力モードの指定が出来ませんでした。。
そもそも -wap-input-format:
これを同じタグで2回指定しているのがいいのかどうか疑問。。どのサイトでもこう書いてありましたが。。
いまは下のように書いています。
<input type="text" name="hoge" istyle="1" format="*M" mode="hiragana" style="<docomoとsoftbankだったら>-wap-input-format:'*<ja:h>;"<条件文終わり> />
auに関してはもうstyle書いてないです。一応今のところこれで指定できてます。(w61tも)
で、docomoとsoftbankの時は -wap-input-format:'*