field-date
一个原生日期输入框,外加 datetime.js 启用的自然语言组合框(除非调用方传了 Plain)。试着输入「明天」。
增强输入:键入“明天”或“3 周后”
<section rst-box><form rst-form method="post" action="#"><div rst-field>
<label rst-field-label for="field-date_live">Publish on</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">The day it goes live.</small>
</div></form></section>
它能解析的词是通过 data-rst-date-words 传出去的,取自这一页的目录:字段解析的正是这一页所用的语言。
必填,并带错误
<section rst-box><form rst-form method="post" action="#"><div rst-field>
<label rst-field-label for="field-date_error">Publish on <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">Pick a date after today.</small>
</div></form></section>
有上下限
<section rst-box><form rst-form method="post" action="#"><div rst-field>
<label rst-field-label for="field-date_bounded">Within this year</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></form></section>
Plain——不加修饰的原生输入框
<section rst-box><form rst-form method="post" action="#"><div rst-field>
<label rst-field-label for="field-date_plain">Publish on</label>
<input rst-input id="field-date_plain" name="field-date_plain" type="date" value="2026-09-04">
</div></form></section>
完全没有增强属性,所以 datetime.js 找不到任何东西。原生选择器照样打得开。