本文へ移動
セクション
Fiesta

field-daterange

日付と時刻 datetime.js が拡張する四つのフィールド。いずれも下にネイティブの入力要素を残すので、スクリプトのない読者には壊れたものではなく素のコントロールが届きます。

開始と終了をひとつのラベル付き fieldset にしたもの。入力欄にはそれぞれ固有の name と id を付けてください。

どの例も実際に動きますが、リンクはどこにも移動しません。 HTML にはコピーできるマークアップがあります。

日付と時刻、初期値あり

終了を空のまま開始を確定すると、datetime.js が終了を一時間後で埋めます。マークアップは何もしていません。しているのはスクリプトです。

プレビュー

これは <section rst-box><form rst-form> の中に置きます。

<fieldset rst-field-range>
  <legend>日時</legend>
  <div rst-field-row data-rst-range="session">
    <div rst-field>
      <label rst-field-label for="dr_starts_at">開始</label>
      <input rst-input id="dr_starts_at" name="dr_starts_at" type="datetime-local" value="2026-09-04T19:30" data-rst-date data-rst-date-words="{&#34;ago&#34;:&#34;前|まえ&#34;,&#34;am&#34;:&#34;午前|am&#34;,&#34;at&#34;:&#34;に&#34;,&#34;day&#34;:&#34;日&#34;,&#34;hour&#34;:&#34;時間|時&#34;,&#34;in&#34;:&#34;後|あと&#34;,&#34;last&#34;:&#34;先|昨|去&#34;,&#34;midnight&#34;:&#34;深夜|真夜中&#34;,&#34;minute&#34;:&#34;分&#34;,&#34;month&#34;:&#34;か月|ヶ月|カ月|月&#34;,&#34;next&#34;:&#34;来|次|翌&#34;,&#34;noon&#34;:&#34;正午|昼&#34;,&#34;pm&#34;:&#34;午後|pm&#34;,&#34;today&#34;:&#34;今日|きょう|本日&#34;,&#34;tomorrow&#34;:&#34;明日|あした|あす&#34;,&#34;week&#34;:&#34;週間|週&#34;,&#34;yesterday&#34;:&#34;昨日|きのう&#34;}" data-rst-date-set="設定" data-rst-date-hint="入力例: {example}" data-rst-date-pick="カレンダーを開く" data-rst-date-calendar="カレンダー" data-rst-date-prev-month="前の月" data-rst-date-next-month="次の月" data-rst-date-results="候補 {n} 件" data-rst-date-result-one="候補 1 件" data-rst-date-quick-today="今日" data-rst-date-quick-tomorrow="明日" data-rst-date-quick-next-week="1週間後" data-rst-date-quick-plus-1h="1時間後" data-rst-date-quick-plus-2h="2時間後" data-rst-date-quick-end-of-day="その日の終わり" data-rst-date-quick-next-day="翌日の同じ時刻">
    </div>
    <div rst-field>
      <label rst-field-label for="dr_ends_at">終了</label>
      <input rst-input id="dr_ends_at" name="dr_ends_at" type="datetime-local" data-rst-date data-rst-date-words="{&#34;ago&#34;:&#34;前|まえ&#34;,&#34;am&#34;:&#34;午前|am&#34;,&#34;at&#34;:&#34;に&#34;,&#34;day&#34;:&#34;日&#34;,&#34;hour&#34;:&#34;時間|時&#34;,&#34;in&#34;:&#34;後|あと&#34;,&#34;last&#34;:&#34;先|昨|去&#34;,&#34;midnight&#34;:&#34;深夜|真夜中&#34;,&#34;minute&#34;:&#34;分&#34;,&#34;month&#34;:&#34;か月|ヶ月|カ月|月&#34;,&#34;next&#34;:&#34;来|次|翌&#34;,&#34;noon&#34;:&#34;正午|昼&#34;,&#34;pm&#34;:&#34;午後|pm&#34;,&#34;today&#34;:&#34;今日|きょう|本日&#34;,&#34;tomorrow&#34;:&#34;明日|あした|あす&#34;,&#34;week&#34;:&#34;週間|週&#34;,&#34;yesterday&#34;:&#34;昨日|きのう&#34;}" data-rst-date-set="設定" data-rst-date-hint="入力例: {example}" data-rst-date-pick="カレンダーを開く" data-rst-date-calendar="カレンダー" data-rst-date-prev-month="前の月" data-rst-date-next-month="次の月" data-rst-date-results="候補 {n} 件" data-rst-date-result-one="候補 1 件" data-rst-date-quick-today="今日" data-rst-date-quick-tomorrow="明日" data-rst-date-quick-next-week="1週間後" data-rst-date-quick-plus-1h="1時間後" data-rst-date-quick-plus-2h="2時間後" data-rst-date-quick-end-of-day="その日の終わり" data-rst-date-quick-next-day="翌日の同じ時刻">
    </div>
  </div>
</fieldset>

日付のみ、終了側にエラー

プレビュー

これは <section rst-box><form rst-form> の中に置きます。

<fieldset rst-field-range>
  <legend>予約</legend>
  <div rst-field-row data-rst-range>
    <div rst-field>
      <label rst-field-label for="dr_from">開始日</label>
      <input rst-input id="dr_from" name="dr_from" type="date" value="2026-09-04" data-rst-date data-rst-date-words="{&#34;ago&#34;:&#34;前|まえ&#34;,&#34;am&#34;:&#34;午前|am&#34;,&#34;at&#34;:&#34;に&#34;,&#34;day&#34;:&#34;日&#34;,&#34;hour&#34;:&#34;時間|時&#34;,&#34;in&#34;:&#34;後|あと&#34;,&#34;last&#34;:&#34;先|昨|去&#34;,&#34;midnight&#34;:&#34;深夜|真夜中&#34;,&#34;minute&#34;:&#34;分&#34;,&#34;month&#34;:&#34;か月|ヶ月|カ月|月&#34;,&#34;next&#34;:&#34;来|次|翌&#34;,&#34;noon&#34;:&#34;正午|昼&#34;,&#34;pm&#34;:&#34;午後|pm&#34;,&#34;today&#34;:&#34;今日|きょう|本日&#34;,&#34;tomorrow&#34;:&#34;明日|あした|あす&#34;,&#34;week&#34;:&#34;週間|週&#34;,&#34;yesterday&#34;:&#34;昨日|きのう&#34;}" data-rst-date-set="設定" data-rst-date-hint="入力例: {example}" data-rst-date-pick="カレンダーを開く" data-rst-date-calendar="カレンダー" data-rst-date-prev-month="前の月" data-rst-date-next-month="次の月" data-rst-date-results="候補 {n} 件" data-rst-date-result-one="候補 1 件" data-rst-date-quick-today="今日" data-rst-date-quick-tomorrow="明日" data-rst-date-quick-next-week="1週間後" data-rst-date-quick-plus-1h="1時間後" data-rst-date-quick-plus-2h="2時間後" data-rst-date-quick-end-of-day="その日の終わり" data-rst-date-quick-next-day="翌日の同じ時刻">
    </div>
    <div rst-field>
      <label rst-field-label for="dr_to">終了日</label>
      <input rst-input id="dr_to" name="dr_to" type="date" value="2026-09-01" aria-invalid="true" aria-describedby="dr_to-error" data-rst-date data-rst-date-words="{&#34;ago&#34;:&#34;前|まえ&#34;,&#34;am&#34;:&#34;午前|am&#34;,&#34;at&#34;:&#34;に&#34;,&#34;day&#34;:&#34;日&#34;,&#34;hour&#34;:&#34;時間|時&#34;,&#34;in&#34;:&#34;後|あと&#34;,&#34;last&#34;:&#34;先|昨|去&#34;,&#34;midnight&#34;:&#34;深夜|真夜中&#34;,&#34;minute&#34;:&#34;分&#34;,&#34;month&#34;:&#34;か月|ヶ月|カ月|月&#34;,&#34;next&#34;:&#34;来|次|翌&#34;,&#34;noon&#34;:&#34;正午|昼&#34;,&#34;pm&#34;:&#34;午後|pm&#34;,&#34;today&#34;:&#34;今日|きょう|本日&#34;,&#34;tomorrow&#34;:&#34;明日|あした|あす&#34;,&#34;week&#34;:&#34;週間|週&#34;,&#34;yesterday&#34;:&#34;昨日|きのう&#34;}" data-rst-date-set="設定" data-rst-date-hint="入力例: {example}" data-rst-date-pick="カレンダーを開く" data-rst-date-calendar="カレンダー" data-rst-date-prev-month="前の月" data-rst-date-next-month="次の月" data-rst-date-results="候補 {n} 件" data-rst-date-result-one="候補 1 件" data-rst-date-quick-today="今日" data-rst-date-quick-tomorrow="明日" data-rst-date-quick-next-week="1週間後" data-rst-date-quick-plus-1h="1時間後" data-rst-date-quick-plus-2h="2時間後" data-rst-date-quick-end-of-day="その日の終わり" data-rst-date-quick-next-day="翌日の同じ時刻">
      <small rst-field-error id="dr_to-error">終了が開始より前になっています。</small>
    </div>
  </div>
</fieldset>