jQuery UI datepicker日期范围 [英] jQuery UI datepicker date range

查看:172
本文介绍了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/

推荐答案

  1. 第一个想法
    • 使用beforeShow而不是onSelect来设置最大/最小日期范围.您仍然可以手动输入错误的值,但是一旦您尝试打开日期选择器,它就会自动更正.
    • 为避免人为篡改,您可以设置readonly字段.
  1. first idea
    • use the beforeShow instead of onSelect 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 and at the same time do some manual checking at the change event of the fields. ( http://jsfiddle.net/s3h5L/4/ )

这篇关于jQuery UI datepicker日期范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆