jQuery UI datepicker日期范围 [英] jQuery UI datepicker date range
本文介绍了jQuery UI datepicker日期范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试设置两个日期选择器,例如 http://jqueryui.com/demos/datepicker/#date-range .但是,如果您在该示例中手动输入日期,则可以破坏代码.例如选择一个起始日期,然后选择器使您无法选择起始日期之前的日期,但是您可以手动输入较早的起始日期.
I am trying to setup two date pickers like this http://jqueryui.com/demos/datepicker/#date-range. But if you manually type in a date into that example you can break the code. e.g. select a from date, then the picker stops you from selecting a date before the from date, but you can manually type in a to date that is earlier.
我在此处设置了示例 http://jsfiddle.net/Ruhley/s3h5L/
推荐答案
- 第一个想法
- 使用
beforeShow
而不是onSelect
来设置最大/最小日期范围.您仍然可以手动输入错误的值,但是一旦您尝试打开日期选择器,它就会自动更正. - 为避免人为篡改,您可以设置
readonly
字段.
- 使用
- first idea
- use the
beforeShow
instead ofonSelect
to set the max/min date range. You still can enter manually wrong values, but as soon as you try to open a datepicker it will auto correct itself. - to avoid manual tampering, you can make
readonly
the fields.
- use the
- 使用
beforeShow
,同时在字段的change
事件中进行一些手动检查. ( http://jsfiddle.net/s3h5L/4/)
- use the
beforeShow
and at the same time do some manual checking at thechange
event of the fields. ( http://jsfiddle.net/s3h5L/4/ )
这篇关于jQuery UI datepicker日期范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文