Tbpgr Blog

Employee Experience Engineer tbpgr(てぃーびー) のブログ

HTML5新要素 input type="month" カレンダーUIで年月の入力

概要

input type="month"タグについて説明します。

内容

input type="month"は月入力欄です。

属性として以下の利用が可能です
max = 最大値を設定
min = 最小値を設定
step = ステップ幅を設定。デフォルトは1月単位

サンプル

<!DOCTYPE HTML>
<html lang="ja-JP">
  <head>
    <meta charset="UTF-8" />
    <title>input type="month"</title>
  </head>
  <body>
  <form action="">
    month:<input type="month" name="month" id="month" value="" max="12" min="1" style="width:200px;" required />
    <input type="submit" name="" value="submit" />
  </form>
  </body>
</html>

完成画面のキャプチャ

現状だと、Opera以外はテキストボックスと変わらない表示なのでOperaのキャプチャです。