jQuery UI Datepicker范围 [英] jQuery UI Datepicker Range

查看:65
本文介绍了jQuery UI Datepicker范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几天前,我问了一个非常相似的问题,但这是足够不同,以至于我不想让其他有用的话题脱轨.我基本上想设置两个文本输入字段,并将它们与jQuery UI的Datepicker挂钩,以使它们充当范围...我希望第二个输入字段的开始日期取决于您在第一个输入中选择的内容场地.例如,如果我为第一个字段选择10-25-2010,那么您可以在第二个字段中选择的最早日期应该是10-26-2010.在这个主题上的任何帮助或指示,将不胜感激!

I asked a pretty similar question a few days ago, but this one is different enough that I didn't feel like derailing the other helpful topic. I basically want to set up two text input fields and hook them both up with jQuery UI's Datepicker to have them act as a range... I want the second input field start date to be contingent upon what you've selected in the first input field. For instance if I select 10-25-2010 for the first field, then the earliest day you can select in the second field should be 10-26-2010. Any help or direction on this topic would be greatly appreciated!

推荐答案

$(function() {

    $('#txtStartDate, #txtEndDate').datepicker({
        showOn: "both",
        beforeShow: customRange,
        dateFormat: "dd M yy",
    });

});

function customRange(input) {

    if (input.id == 'txtEndDate') {
        var minDate = new Date($('#txtStartDate').val());
        minDate.setDate(minDate.getDate() + 1)

        return {
            minDate: minDate

        };
    }

}​

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

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