field-time
日期与时间 datetime.js 增强的四个字段,每个都在底层保留原生输入控件,因此没有脚本的读者得到的是朴素的控件,而不是坏掉的控件。
同样的外壳,包着一个原生时间输入框。这次增强读的是钟点,不是日历。
每个示例都能真实操作,但其中的链接不会跳转到任何地方。 HTML 显示可复制的标记。
增强输入:键入“七点半”或“中午”
把这段放进 <section rst-box><form rst-form> 里。
<div rst-field >
<label rst-field-label for ="time_live" >开门时间</label >
<input rst-input id ="time_live" name ="time_live" type ="time" value ="19:30" aria-describedby ="time_live-hint" data-rst-time 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-pick-time ="打开时钟" 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 ="time_live-hint" >当地时间。</small >
</div >
必填,并带错误
把这段放进 <section rst-box><form rst-form> 里。
<div rst-field >
<label rst-field-label for ="time_error" >开门时间 <span rst-field-required aria-hidden ="true" >*</span ></label >
<input rst-input id ="time_error" name ="time_error" type ="time" required aria-invalid ="true" aria-describedby ="time_error-error" data-rst-time 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-pick-time ="打开时钟" 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 ="time_error-error" >请选择试音之后的时间。</small >
</div >
有上下限
把这段放进 <section rst-box><form rst-form> 里。
<div rst-field >
<label rst-field-label for ="time_bounded" >九点到十一点之间</label >
<input rst-input id ="time_bounded" name ="time_bounded" type ="time" value ="19:30" min ="09:00" max ="23:00" data-rst-time 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-pick-time ="打开时钟" 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 >
Plain:不加修饰的原生输入框
把这段放进 <section rst-box><form rst-form> 里。
<div rst-field >
<label rst-field-label for ="time_plain" >开门时间</label >
<input rst-input id ="time_plain" name ="time_plain" type ="time" value ="19:30" >
</div >