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 ="一個星期之後" data-rst-date-quick-plus-1h ="一個鐘之後" data-rst-date-quick-plus-2h ="兩個鐘之後" 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 ="一個星期之後" data-rst-date-quick-plus-1h ="一個鐘之後" data-rst-date-quick-plus-2h ="兩個鐘之後" 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 ="一個星期之後" data-rst-date-quick-plus-1h ="一個鐘之後" data-rst-date-quick-plus-2h ="兩個鐘之後" 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 ="一個星期之後" data-rst-date-quick-plus-1h ="一個鐘之後" data-rst-date-quick-plus-2h ="兩個鐘之後" 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 >