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 ="{"ago":"前|まえ","am":"午前|am","at":"に","day":"日","hour":"時間|時","in":"後|あと","last":"先|昨|去","midnight":"深夜|真夜中","minute":"分","month":"か月|ヶ月|カ月|月","next":"来|次|翌","noon":"正午|昼","pm":"午後|pm","today":"今日|きょう|本日","tomorrow":"明日|あした|あす","week":"週間|週","yesterday":"昨日|きのう"}" 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 ="{"ago":"前|まえ","am":"午前|am","at":"に","day":"日","hour":"時間|時","in":"後|あと","last":"先|昨|去","midnight":"深夜|真夜中","minute":"分","month":"か月|ヶ月|カ月|月","next":"来|次|翌","noon":"正午|昼","pm":"午後|pm","today":"今日|きょう|本日","tomorrow":"明日|あした|あす","week":"週間|週","yesterday":"昨日|きのう"}" 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 ="{"ago":"前|まえ","am":"午前|am","at":"に","day":"日","hour":"時間|時","in":"後|あと","last":"先|昨|去","midnight":"深夜|真夜中","minute":"分","month":"か月|ヶ月|カ月|月","next":"来|次|翌","noon":"正午|昼","pm":"午後|pm","today":"今日|きょう|本日","tomorrow":"明日|あした|あす","week":"週間|週","yesterday":"昨日|きのう"}" 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 ="{"ago":"前|まえ","am":"午前|am","at":"に","day":"日","hour":"時間|時","in":"後|あと","last":"先|昨|去","midnight":"深夜|真夜中","minute":"分","month":"か月|ヶ月|カ月|月","next":"来|次|翌","noon":"正午|昼","pm":"午後|pm","today":"今日|きょう|本日","tomorrow":"明日|あした|あす","week":"週間|週","yesterday":"昨日|きのう"}" 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 >