パスワードをautocompleteさせたくないときのメモ。
- 案1.formにautocomplete=”off”を定義してみる。
- 結果はNGでした。 普通にパスワードが設定されてました。
- 案2.input type=”password”をtype=”text”に変更してみる。
- 結果はOKでした。パスワードは設定されませんでしたが、パスワードっぽくない。
- 案3.案2をやったあとにwindow.onload後にinput type=”password”に変更してみる。
- 結果はNGでした。パスワードが設定されている状態でした。
- 案4.案3を改良して、少しdelayをかけてからinput type=”password”に変更してみる。
- 結果はOKでした。これが一番まともな気がします。
こんな感じにするとうまく動作しました。
1 2 3 4 5 6 7 8 9 10 |
// 読み込み完了に実行 $(window).load(function() { $(this).delay(200).queue(function() { //textをpasswordに変更 $("#form_password").attr('type', 'password'); }); }); <input type="email" placeholder="メールアドレスを入力してください" required="required" id="form_email" name="email" value=""> <input type="text" placeholder="パスワードを入力してください" required="required" id="form_password" name="password" value=""> |
参考サイト
http://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q13146625208
https://developer.mozilla.org/ja/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion
One comment to this article
Pokey
on 2016年11月16日 at 8:46 PM -
The exstierpe shines through. Thanks for taking the time to answer.