{
    "componentChunkName": "component---src-templates-blog-post-jsx",
    "path": "/post/how-to-implement-frequency-ui-in-form/",
    "result": {"data":{"site":{"siteMetadata":{"title":"WEB EGG","author":"Leko - CTO at Yuimedi"}},"markdownRemark":{"id":"7e20673f-031a-52d4-8edb-fede235192cb","excerpt":"れこです。 Hamee Advent Calendar 2015 2 日目の記事です。 「明日使えるフロントエンドと作業効率化の備忘録」とか銘打っておきながら、 フロントエンドの記事を書くのはものすごく久々な気がします。 フォームや input…","html":"<p>れこです。<br>\n<a href=\"http://qiita.com/advent-calendar/2015/hamee\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Hamee Advent Calendar 2015</a> 2 日目の記事です。</p>\n<p><del>「明日使えるフロントエンドと作業効率化の備忘録」とか銘打っておきながら、<br /> フロントエンドの記事を書くのはものすごく久々な気がします。</del></p>\n<p>フォームや input 周りを扱っていると、毎回小さな機能を作るたびググって毎回使用するライブラリや実装が揺れてしまうので、<br>\n2015/11/24 現在での決定版を調べてまとめて備忘録にします。</p>\n<!--more-->\n<h2 id=\"まえおき\" style=\"position:relative;\"><a href=\"#%E3%81%BE%E3%81%88%E3%81%8A%E3%81%8D\" aria-label=\"まえおき permalink\" class=\"autolink-header before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>まえおき</h2>\n<p>当記事で紹介するライブラリ、コードを<a href=\"https://jsfiddle.net/leko/znos4wf0/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">全部まとめたデモを作りました</a>。<br>\n記事と内容を読みつつ、具体的なコードはデモをご参照ください。<br>\n<strong>記事内にはコードはほとんど書きません</strong> 。デモがあるのと、README の内容をコピー&#x26;ペーストしてもすぐ情報が古くなるためです。</p>\n<p>また、ライブラリを採用する場合には以下の採用基準で選んでいます</p>\n<ul>\n<li>使いやすい、拡張しやすい（一部妥協有り）</li>\n<li>Github でホスティングされている</li>\n<li>デモ、ドキュメントが存在する</li>\n<li>一定以上 star がついている\n<ul>\n<li>※分野により最大スター数がまちまちなので、実際は独断と偏見で判断</li>\n</ul>\n</li>\n<li>メンテナンス面\n<ul>\n<li>現在もメンテナンスされている、もしくはきちんと枯れてるもの</li>\n<li>長い目でサポートされそう</li>\n</ul>\n</li>\n</ul>\n<p>前置きは以上です</p>\n<h2 id=\"パスワードの表示非表示を切り替える\" style=\"position:relative;\"><a href=\"#%E3%83%91%E3%82%B9%E3%83%AF%E3%83%BC%E3%83%89%E3%81%AE%E8%A1%A8%E7%A4%BA%E9%9D%9E%E8%A1%A8%E7%A4%BA%E3%82%92%E5%88%87%E3%82%8A%E6%9B%BF%E3%81%88%E3%82%8B\" aria-label=\"パスワードの表示非表示を切り替える permalink\" class=\"autolink-header before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>パスワードの表示/非表示を切り替える</h2>\n<ul>\n<li>リポジトリ: <a href=\"https://github.com/cloudfour/hideShowPassword\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://github.com/cloudfour/hideShowPassword</a></li>\n<li>デモ: <a href=\"http://cloudfour.github.io/hideShowPassword/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">http://cloudfour.github.io/hideShowPassword/</a></li>\n</ul>\n<p><img src=\"https://i.stack.imgur.com/GQ5Yh.png\" alt=\"pwd-demo\"> IE10 から取り入れられた「パスワードを表示/非表示する」ボタンです。<br>\n詳しくは<a href=\"http://answers.microsoft.com/en-us/ie/wiki/ie11-iewindows8_1/the-use-of-the-password-reveal-eye-button-in-ie10/19a9dee2-fb0c-4c26-a6bc-ac02cf98d80e\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">こちら(公式, 英語)</a>のブログで紹介されています。</p>\n<p>スマフォ web 版 Facebook のログイン画面にも「パスワードを表示する」機能があったりします。</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 668px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/7af6ccfb5981c9733295df80e026ba02/9888a/20151124010528.jpg\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 92.21556886227545%; position: relative; bottom: 0; left: 0; background-image: url('data:image/svg+xml,%3csvg%20xmlns=\\'http://www.w3.org/2000/svg\\'%20width=\\'400\\'%20height=\\'368\\'%20viewBox=\\'0%200%20400%20368\\'%20preserveAspectRatio=\\'none\\'%3e%3cpath%20d=\\'M368%2011l1%205h8v-4l-1-5h15v5c0%202%200%204%201%203l1-2%201-2-1-2-1-1c0-2-2-2-12-2h-12v5M1%2069L0%2093v23h401V68H202L1%2069m149%2013l-2%203-1%203-2%202%202%202%201%205c0%204%200%205%202%205s2-1%202-5%200-5%202-5l1-2-1-2-2-1%201-2%202-2c0-2-2-3-5-1m48%200l-1%2010v10h8c3%200%205-3%205-7%200-5-3-8-6-7s-3%201-3-2c0-4-1-5-3-4m44%2010c0%209%200%2010%202%2010s2-1%202-3v-3l2%203c1%202%202%203%204%203h2l-2-3-2-4%202-3%202-4h-2l-4%204-2%203v-7c0-6%200-7-2-7s-2%201-2%2011m-84-2c-2%202-3%207-1%2010%201%202%202%202%207%202h5v-7l-1-6-5-1c-3%200-4%200-5%202m27-1l-3%204c-1%206%203%2010%209%209%204%200%204-3%200-3l-4-1c-1-1%201-1%203-1%205%200%205%200%205-2%200-5-5-8-10-6m29%201c-1%201-2%202-2%205%200%205%202%207%207%207%204%200%206-2%206-7%200-6-6-9-11-5m15%200c-3%202-3%209%200%2011%205%203%2011%200%2011-6s-6-9-11-5M34%20144v17l1%2014h17v-15c0-18%200-18-10-18-6%200-7%200-8%202m1%2011c0%208%201%2010%204%208l1-7c0-5%200-6%202-6%203%200%205%204%203%208-1%202-1%203%201%204%204%203%204%202%205-7v-8H35v8m275%20122v23h78v-46h-78v23m6-17l-1%2018v17h68v-36h-33l-34%201M18%20312c-2%202-2%203-2%2018l1%2018c2%203%20364%203%20366%200l1-18c0-15%200-16-2-18-3-3-361-3-364%200\\'%20fill=\\'%23d3d3d3\\'%20fill-rule=\\'evenodd\\'/%3e%3c/svg%3e'); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/7af6ccfb5981c9733295df80e026ba02/5251b/20151124010528.webp 167w,\n/static/7af6ccfb5981c9733295df80e026ba02/7390e/20151124010528.webp 334w,\n/static/7af6ccfb5981c9733295df80e026ba02/7c056/20151124010528.webp 668w,\n/static/7af6ccfb5981c9733295df80e026ba02/0a92e/20151124010528.webp 1002w,\n/static/7af6ccfb5981c9733295df80e026ba02/40d0b/20151124010528.webp 1198w\"\n              sizes=\"(max-width: 668px) 100vw, 668px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/7af6ccfb5981c9733295df80e026ba02/d0ba8/20151124010528.jpg 167w,\n/static/7af6ccfb5981c9733295df80e026ba02/20f07/20151124010528.jpg 334w,\n/static/7af6ccfb5981c9733295df80e026ba02/fdf4b/20151124010528.jpg 668w,\n/static/7af6ccfb5981c9733295df80e026ba02/332df/20151124010528.jpg 1002w,\n/static/7af6ccfb5981c9733295df80e026ba02/9888a/20151124010528.jpg 1198w\"\n            sizes=\"(max-width: 668px) 100vw, 668px\"\n            type=\"image/jpeg\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/7af6ccfb5981c9733295df80e026ba02/fdf4b/20151124010528.jpg\"\n            alt=\"20151124010528\"\n            title=\"20151124010528\"\n            loading=\"lazy\"\n            decoding=\"async\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>パスワードは入力しても「●●●●」のようになってしまうため、打ち間違えた場合にも中身が見えません。<br>\n特に打ち間違えやすいスマートフォンなどでは、表示/非表示の切り替えがあると親切な場合があるかもしれません。</p>\n<p>パスワードが画面に出てしまうのでソーシャルエンジニアリングのリスクが発生しますが、<br>\nそこはソースコードには関係ない要件や決めの問題なので、この記事では考慮しません。ご利用の際はご留意ください。</p>\n<h2 id=\"クリックしたら全選択\" style=\"position:relative;\"><a href=\"#%E3%82%AF%E3%83%AA%E3%83%83%E3%82%AF%E3%81%97%E3%81%9F%E3%82%89%E5%85%A8%E9%81%B8%E6%8A%9E\" aria-label=\"クリックしたら全選択 permalink\" class=\"autolink-header before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>クリックしたら全選択</h2>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 668px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/eb714f004feff92de29905efe2b5c579/e6c84/Screen-Shot-2015-11-24-at-1.33.10-AM.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 35.92814371257485%; position: relative; bottom: 0; left: 0; background-image: url('data:image/svg+xml,%3csvg%20xmlns=\\'http://www.w3.org/2000/svg\\'%20width=\\'400\\'%20height=\\'143\\'%20viewBox=\\'0%200%20400%20143\\'%20preserveAspectRatio=\\'none\\'%3e%3cpath%20d=\\'M196%2056v3h204v-6H196v3m117%2022v9H169v-8l-1-7v16h146v-9l-1-9v8m67%200c-1%204%201%205%204%203h7l1-1c0%202%202%203%202%201h1c0%202%202%201%203-1v-2l1%202c1%202%201%202%201-1%200-2%200-3-3-3l-3%201h-1l-5-1h-3l-2-1c-2%200-3%201-3%203\\'%20fill=\\'%23d3d3d3\\'%20fill-rule=\\'evenodd\\'/%3e%3c/svg%3e'); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/eb714f004feff92de29905efe2b5c579/5251b/Screen-Shot-2015-11-24-at-1.33.10-AM.webp 167w,\n/static/eb714f004feff92de29905efe2b5c579/7390e/Screen-Shot-2015-11-24-at-1.33.10-AM.webp 334w,\n/static/eb714f004feff92de29905efe2b5c579/7c056/Screen-Shot-2015-11-24-at-1.33.10-AM.webp 668w,\n/static/eb714f004feff92de29905efe2b5c579/0a92e/Screen-Shot-2015-11-24-at-1.33.10-AM.webp 1002w,\n/static/eb714f004feff92de29905efe2b5c579/d8c59/Screen-Shot-2015-11-24-at-1.33.10-AM.webp 1148w\"\n              sizes=\"(max-width: 668px) 100vw, 668px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/eb714f004feff92de29905efe2b5c579/21521/Screen-Shot-2015-11-24-at-1.33.10-AM.png 167w,\n/static/eb714f004feff92de29905efe2b5c579/86d36/Screen-Shot-2015-11-24-at-1.33.10-AM.png 334w,\n/static/eb714f004feff92de29905efe2b5c579/74866/Screen-Shot-2015-11-24-at-1.33.10-AM.png 668w,\n/static/eb714f004feff92de29905efe2b5c579/d69c4/Screen-Shot-2015-11-24-at-1.33.10-AM.png 1002w,\n/static/eb714f004feff92de29905efe2b5c579/e6c84/Screen-Shot-2015-11-24-at-1.33.10-AM.png 1148w\"\n            sizes=\"(max-width: 668px) 100vw, 668px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/eb714f004feff92de29905efe2b5c579/74866/Screen-Shot-2015-11-24-at-1.33.10-AM.png\"\n            alt=\"undefined\"\n            title=\"undefined\"\n            loading=\"lazy\"\n            decoding=\"async\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>Github のリポジトリの URL（上記画像を参考）のように、フォーカスを当てたら全選択される要素の作り方です。</p>\n<p>ライブラリを使うほどではなく、こちらの<a href=\"http://stackoverflow.com/questions/13887430/select-all-text-in-an-input-when-it-gains-focus\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Stackoverflow の質問</a>にわかりやすくまとまっていました。<br>\nライブラリ化するほどか否か迷いますが、多用するならきちんとコンポーネント化しておいたほうが良いと思います。</p>\n<p>ざっくり jQuery プラグイン化するなら、こんな感じかと思います。</p>\n<div class=\"gatsby-highlight\" data-language=\"html\"><pre class=\"language-html\"><code class=\"language-html\"><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>input</span>\n  <span class=\"token attr-name\">type</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>url<span class=\"token punctuation\">\"</span></span>\n  <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>form-control focus-then-select<span class=\"token punctuation\">\"</span></span>\n  <span class=\"token attr-name\">readonly</span>\n  <span class=\"token attr-name\">value</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>ssh://hoge.git<span class=\"token punctuation\">\"</span></span>\n<span class=\"token punctuation\">/></span></span></code></pre></div>\n<div class=\"gatsby-highlight\" data-language=\"javascript\"><pre class=\"language-javascript\"><code class=\"language-javascript\">jQuery<span class=\"token punctuation\">.</span>fn<span class=\"token punctuation\">.</span><span class=\"token function-variable function\">focusThenSelect</span> <span class=\"token operator\">=</span> <span class=\"token keyword\">function</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token keyword\">this</span><span class=\"token punctuation\">.</span><span class=\"token function\">on</span><span class=\"token punctuation\">(</span><span class=\"token string\">'focus'</span><span class=\"token punctuation\">,</span> <span class=\"token keyword\">function</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n    <span class=\"token keyword\">this</span><span class=\"token punctuation\">.</span><span class=\"token function\">select</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span>\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span>\n<span class=\"token punctuation\">}</span>\n<span class=\"token function\">$</span><span class=\"token punctuation\">(</span><span class=\"token string\">'input.focus-then-select'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span><span class=\"token function\">focusThenSelect</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span></code></pre></div>\n<h2 id=\"タグっぽいものを入力する\" style=\"position:relative;\"><a href=\"#%E3%82%BF%E3%82%B0%E3%81%A3%E3%81%BD%E3%81%84%E3%82%82%E3%81%AE%E3%82%92%E5%85%A5%E5%8A%9B%E3%81%99%E3%82%8B\" aria-label=\"タグっぽいものを入力する permalink\" class=\"autolink-header before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>タグっぽいものを入力する</h2>\n<ul>\n<li>リポジトリ: <a href=\"https://github.com/brianreavis/selectize.js/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://github.com/brianreavis/selectize.js/</a></li>\n<li>デモ: <a href=\"https://brianreavis.github.io/selectize.js/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://brianreavis.github.io/selectize.js/</a></li>\n</ul>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 668px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/93891342ff37879242cad21ab34167ba/05fb0/Screen-Shot-2015-11-24-at-1.50.23-AM.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 28.74251497005988%; position: relative; bottom: 0; left: 0; background-image: url('data:image/svg+xml,%3csvg%20xmlns=\\'http://www.w3.org/2000/svg\\'%20width=\\'400\\'%20height=\\'114\\'%20viewBox=\\'0%200%20400%20114\\'%20preserveAspectRatio=\\'none\\'%3e%3cpath%20d=\\'M37%209c-1%208%200%2010%202%2010l3-1h3l3%201c3-1%203-4%200-5-2-1-2-1%200-1l2-3c1-2%201-2-2-2s-3%201-3%204-1%203-4%202c-2%200-2%200%200-2%203-2%203-4-1-4l-3%201M24%2073l1%209h49l1-2V66l-26-1H24v8m53-6v14l15%201c15%200%2014%200%2014-11v-5l-15-1c-12%200-14%200-14%202\\'%20fill=\\'%23d3d3d3\\'%20fill-rule=\\'evenodd\\'/%3e%3c/svg%3e'); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/93891342ff37879242cad21ab34167ba/5251b/Screen-Shot-2015-11-24-at-1.50.23-AM.webp 167w,\n/static/93891342ff37879242cad21ab34167ba/7390e/Screen-Shot-2015-11-24-at-1.50.23-AM.webp 334w,\n/static/93891342ff37879242cad21ab34167ba/7c056/Screen-Shot-2015-11-24-at-1.50.23-AM.webp 668w,\n/static/93891342ff37879242cad21ab34167ba/0a92e/Screen-Shot-2015-11-24-at-1.50.23-AM.webp 1002w,\n/static/93891342ff37879242cad21ab34167ba/22e6c/Screen-Shot-2015-11-24-at-1.50.23-AM.webp 1138w\"\n              sizes=\"(max-width: 668px) 100vw, 668px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/93891342ff37879242cad21ab34167ba/21521/Screen-Shot-2015-11-24-at-1.50.23-AM.png 167w,\n/static/93891342ff37879242cad21ab34167ba/86d36/Screen-Shot-2015-11-24-at-1.50.23-AM.png 334w,\n/static/93891342ff37879242cad21ab34167ba/74866/Screen-Shot-2015-11-24-at-1.50.23-AM.png 668w,\n/static/93891342ff37879242cad21ab34167ba/d69c4/Screen-Shot-2015-11-24-at-1.50.23-AM.png 1002w,\n/static/93891342ff37879242cad21ab34167ba/05fb0/Screen-Shot-2015-11-24-at-1.50.23-AM.png 1138w\"\n            sizes=\"(max-width: 668px) 100vw, 668px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/93891342ff37879242cad21ab34167ba/74866/Screen-Shot-2015-11-24-at-1.50.23-AM.png\"\n            alt=\"undefined\"\n            title=\"undefined\"\n            loading=\"lazy\"\n            decoding=\"async\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>語彙力が足りずすみません。上記画像のような UI です。<br>\nBootstrap3 用に最適化された CSS も公式で対応していたりします。「流石の star 数である」と感嘆するクオリティです。</p>\n<h2 id=\"インクリメンタルサーチする\" style=\"position:relative;\"><a href=\"#%E3%82%A4%E3%83%B3%E3%82%AF%E3%83%AA%E3%83%A1%E3%83%B3%E3%82%BF%E3%83%AB%E3%82%B5%E3%83%BC%E3%83%81%E3%81%99%E3%82%8B\" aria-label=\"インクリメンタルサーチする permalink\" class=\"autolink-header before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>インクリメンタルサーチする</h2>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 668px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/22f52b6a5b41d96a0e33d0fd14a149f9/05fb0/Screen-Shot-2015-11-24-at-3.13.51-AM.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 51.49700598802396%; position: relative; bottom: 0; left: 0; background-image: url('data:image/svg+xml,%3csvg%20xmlns=\\'http://www.w3.org/2000/svg\\'%20width=\\'400\\'%20height=\\'206\\'%20viewBox=\\'0%200%20400%20206\\'%20preserveAspectRatio=\\'none\\'%3e%3cpath%20d=\\'M59%2064h-3l-2%201h-8l-2-1c-3%200-3%200-3%204%200%203%201%204%204%202%201-1%202-2%203-1h6c1%202%204%200%204-2v-1l1%202c0%201%201%202%204%202%202%200%203-1%203-2v-3l-2-1h-5M16%2086c-2%201-2%202-1%204%200%202%206%203%206%201h7l4%201c3%200%204%200%205-2v-2l1%202%202%202%201%201c0%202%204%201%205-2%200-3-2-6-4-4h-3c-2-1-4%200-4%202s0%202-1%200c-1-3-3-4-4-1-1%202-1%202-1%200%200-3%200-3-1-1%200%202%200%202-2%201-2-2-2-2-3-1s-2%202-3%201c-2%200-2%200-1%201v1c-2%201-3%200-3-2s0-2%203-2h1c-2-2-2-2-4%200m93%2053c0%203%200%203%202%202l3-1h5c2-2%202-2%203%200h6c1%202%204%200%204-2s-2-4-4-2h-14l-2-1c-3%200-3%200-3%204m-58%2014c-2%202-2%2013%201%2013v5c-3%201-2%202%201%202h2l1%201c2-1%201-3%200-3-3%200-2-4%200-5%203%200%203-13%200-14-2-1-3-1-5%201m-31%207c1%204%201%205-1%203%200-3-2-2-2%200v3l-1%201c-1-1-1%200-1%203%200%202%200%203%202%203h24c1%202%207%201%207%200l2-3c2-1%203-3%201-3-2%201-2%200-2-4l-1-5-6%2010-2%202c0-2-7-10-8-9s-1%201-1-1c0-5-4-4-4%200%200%202%200%202-1%200s-1-2-2-1c-2%201-2%201-2-1-2-4-3-2-2%202m-6%2034l1%2011%2018%201h17l1-5c1-6%203-8%204-6v2c-2-1-2-1-1%202%201%201%201%203-1%204-1%203-1%203%202%203%202%200%203%200%203-2v-18c0-2%200-2-11-2H35l-2%204-2%204v-4l1-3-9-1h-9v10\\'%20fill=\\'%23d3d3d3\\'%20fill-rule=\\'evenodd\\'/%3e%3c/svg%3e'); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/22f52b6a5b41d96a0e33d0fd14a149f9/5251b/Screen-Shot-2015-11-24-at-3.13.51-AM.webp 167w,\n/static/22f52b6a5b41d96a0e33d0fd14a149f9/7390e/Screen-Shot-2015-11-24-at-3.13.51-AM.webp 334w,\n/static/22f52b6a5b41d96a0e33d0fd14a149f9/7c056/Screen-Shot-2015-11-24-at-3.13.51-AM.webp 668w,\n/static/22f52b6a5b41d96a0e33d0fd14a149f9/0a92e/Screen-Shot-2015-11-24-at-3.13.51-AM.webp 1002w,\n/static/22f52b6a5b41d96a0e33d0fd14a149f9/22e6c/Screen-Shot-2015-11-24-at-3.13.51-AM.webp 1138w\"\n              sizes=\"(max-width: 668px) 100vw, 668px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/22f52b6a5b41d96a0e33d0fd14a149f9/21521/Screen-Shot-2015-11-24-at-3.13.51-AM.png 167w,\n/static/22f52b6a5b41d96a0e33d0fd14a149f9/86d36/Screen-Shot-2015-11-24-at-3.13.51-AM.png 334w,\n/static/22f52b6a5b41d96a0e33d0fd14a149f9/74866/Screen-Shot-2015-11-24-at-3.13.51-AM.png 668w,\n/static/22f52b6a5b41d96a0e33d0fd14a149f9/d69c4/Screen-Shot-2015-11-24-at-3.13.51-AM.png 1002w,\n/static/22f52b6a5b41d96a0e33d0fd14a149f9/05fb0/Screen-Shot-2015-11-24-at-3.13.51-AM.png 1138w\"\n            sizes=\"(max-width: 668px) 100vw, 668px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/22f52b6a5b41d96a0e33d0fd14a149f9/74866/Screen-Shot-2015-11-24-at-3.13.51-AM.png\"\n            alt=\"undefined\"\n            title=\"undefined\"\n            loading=\"lazy\"\n            decoding=\"async\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>タグっぽい入力でも紹介した Selectize にかかれば、インクリメンタルサーチもお手のものです。</p>\n<p>選択候補を Ajax で読み取ったり、あいまい検索もできたりといい感じです。<br>\nただし結構ゴリゴリと js を書く必要があるので注意です。</p>\n<blockquote>\n<p>ちなみに、React で似たようなインクリメンタルサーチを実装するなら<a href=\"https://github.com/furqanZafar/react-selectize\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">furqanZafar/react-selectize</a>がよさそうでした。デモでは React を取り扱っていませんが紹介です。</p>\n</blockquote>\n<h2 id=\"郵便番号から住所検索\" style=\"position:relative;\"><a href=\"#%E9%83%B5%E4%BE%BF%E7%95%AA%E5%8F%B7%E3%81%8B%E3%82%89%E4%BD%8F%E6%89%80%E6%A4%9C%E7%B4%A2\" aria-label=\"郵便番号から住所検索 permalink\" class=\"autolink-header before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>郵便番号から住所検索</h2>\n<ul>\n<li>リポジトリ: <a href=\"https://github.com/ajaxzip3/ajaxzip3.github.io\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://github.com/ajaxzip3/ajaxzip3.github.io</a></li>\n<li>デモ: <a href=\"https://ajaxzip3.github.io/sample-page/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://ajaxzip3.github.io/sample-page/</a></li>\n</ul>\n<p><a href=\"https://thebase.in\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">BASE</a>というネットショップを作成できるサービスの、購入者情報を入力する画面では<a href=\"http://www.kawa.net/works/ajax/ajaxzip2/ajaxzip2.html\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">AjaxZip 2.0 – Ajax 郵便番号 → 住所自動入力フォーム（CGI 不要版）</a>というライブラリが使用されていました。</p>\n<blockquote>\n<p>— <a href=\"http://blog.motoo.net/2010/10/15/102802\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">いつのまにか ajaxzip が進化して、メンテ不要の住所入力支援ツールになっててビビった件。</a></p>\n</blockquote>\n<p>Google code が廃れ、Github に移転し、郵便番号データを保持する必要がなくなり、バージョン 3 だそうです（スターが全然ついてないのが怖い）</p>\n<p>こういったライブラリ、サービスを利用すればサーバに郵便番号マスタや差分更新バッチを持たなくても良いのですが、 <strong>代償として非公式の外部リソースに依存する</strong> のってどうなんでしょう。。。<br>\n郵便番号を検索する API を公開している人は多いものの、全部非公式なのでどうにも不安です。<br>\nなら自社で郵便番号を検索できるサービスをマイクロサービスとして切り出して運用とかのほうがマシかもしれません。</p>\n<p>そもそも<a href=\"http://www.post.japanpost.jp/zipcode/download.html\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">郵便番号一覧を公開している</a>日本郵便さん公式で API を公開・運用してくれればこんな悩みを抱えずに済むのに…</p>\n<h2 id=\"まとめ\" style=\"position:relative;\"><a href=\"#%E3%81%BE%E3%81%A8%E3%82%81\" aria-label=\"まとめ permalink\" class=\"autolink-header before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>まとめ</h2>\n<p>以上です。他に思いつくものがありましたら調査して乗せます。<br>\nもし調査の希望や「これいいよ！」等がございましたらコメントにてご連絡いただけると幸いです。</p>","timeToRead":7,"frontmatter":{"title":"フォーム周りで地味に使うUIと実現方法","tags":["Advent Calendar","JavaScript","Qiita"],"date":"December 01, 2015","featuredImage":null}}},"pageContext":{"slug":"/how-to-implement-frequency-ui-in-form/","previous":{"fields":{"slug":"/research-of-log-collection-and-monitoring-in-heroku/"},"frontmatter":{"title":"Herokuでのログ収集と監視について調べてみた","tags":["fluentd","Go","Heroku","Papertrail","TreasureData"]}},"next":{"fields":{"slug":"/how-to-test-api-server-with-api-spec/"},"frontmatter":{"title":"APIドキュメントでAPIサーバをテストする","tags":["API","API Blueprint","Dredd","Go","Nodejs"]}}}},
    "staticQueryHashes": ["2585454260","2954598359"]}