field-date
原生日期輸入框,加上 datetime.js 開嘅自然語言組合框(除非叫佢嗰陣傳咗 Plain)。試吓打「聽日」入去。
增強輸入:打「聽日」或者「3 個星期後」
將呢段放入 <section rst-box><form rst-form> 入面。
<div rst-field >
<label rst-field-label for ="field-date_live" >發佈日期</label >
<input rst-input id ="field-date_live" name ="field-date_live" type ="date" value ="2026-09-04" aria-describedby ="field-date_live-hint" 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-hint id ="field-date_live-hint" >上線嗰日。</small >
</div >
將呢段放入 <section rst-box><form rst-form> 入面。
{{ template "field-date" dict
"Name" "field-date_live"
"Label" "發佈日期"
"Value" "2026-09-04"
"Hint" "上線嗰日。" }}
佢識解嘅字係經 data-rst-date-words 傳出去嘅,由呢一版嘅目錄查返嚟:個欄位解嘅就係呢一版用緊嗰種語言。
必填,仲有錯誤
將呢段放入 <section rst-box><form rst-form> 入面。
<div rst-field >
<label rst-field-label for ="field-date_error" >發佈日期 <span rst-field-required aria-hidden ="true" >*</span ></label >
<input rst-input id ="field-date_error" name ="field-date_error" type ="date" required aria-invalid ="true" aria-describedby ="field-date_error-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 ="field-date_error-error" >揀一個今日之後嘅日子。</small >
</div >
將呢段放入 <section rst-box><form rst-form> 入面。
{{ template "field-date" dict
"Name" "field-date_error"
"Label" "發佈日期"
"Required" true
"Error" "揀一個今日之後嘅日子。" }}
有上下限
將呢段放入 <section rst-box><form rst-form> 入面。
<div rst-field >
<label rst-field-label for ="field-date_bounded" >今年之內</label >
<input rst-input id ="field-date_bounded" name ="field-date_bounded" type ="date" value ="2026-09-04" min ="2026-01-01" max ="2026-12-31" 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 >
將呢段放入 <section rst-box><form rst-form> 入面。
{{ template "field-date" dict
"Name" "field-date_bounded"
"Label" "今年之內"
"Value" "2026-09-04"
"Min" "2026-01-01"
"Max" "2026-12-31" }}
Plain:冇加嘢嘅原生輸入框
將呢段放入 <section rst-box><form rst-form> 入面。
<div rst-field >
<label rst-field-label for ="field-date_plain" >發佈日期</label >
<input rst-input id ="field-date_plain" name ="field-date_plain" type ="date" value ="2026-09-04" >
</div >
將呢段放入 <section rst-box><form rst-form> 入面。
{{ template "field-date" dict
"Name" "field-date_plain"
"Label" "發佈日期"
"Value" "2026-09-04"
"Plain" true }}
完全冇加強用嘅屬性,所以 datetime.js 搵唔到嘢。原生揀選器照樣開得到。