jQuery datepicker mindate, maxdate [英] jQuery datepicker mindate, maxdate

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

问题描述

我有以下两个 datepicker 对象,但我无法得到我想要的,因为我被 minDate 和 maxDate 选项卡住了:

I have the two following datepicker objects but I can't get what I want as I am getting stuck with the minDate and maxDate options:

这是为了将日期限制为未来的日期.

我想要什么:将日期从当前日期限制为 30 年时间.

What I want: restrict the dates from current date to 30 years time.

我得到了什么:将日期从当前日期限制为 10 年时间.

What I get: restrict the dates from current date to 10 years time.

$(".datepickerFuture").datepicker({
    showOn: "button",
    buttonImage: 'calendar.gif',
    buttonText: 'Click to select a date',
    duration:"fast",
    changeMonth: true,
    changeYear: true,
    dateFormat: 'dd/mm/yy',
    constrainInput: true,
    minDate: 0,
    maxDate: '+30Y',    
        buttonImageOnly: true
    });

这是为了限制只选择过去的日期:

我想要什么:将日期从当前日期限制为 120 年前的时间.

What I want: restrict the dates from current date to 120 years ago time.

我得到什么:将日期从当前日期限制为 120 年前的时间,但是当我选择一年时,最大年份将重置为所选年份(例如,当页面加载时我会得到什么新鲜的是 1890-2010,但如果我选择 2000 年选择框重置为 1880-2000) .

What I get: restrict the dates from current date to 120 years ago time, but when I select a year the maximum year will reset to selected year (e.g. what I would get when page load from fresh is 1890-2010, but if I select 2000 the year select box reset to 1880-2000) .

$(".datepickerPast").datepicker({
    showOn: "button",
   buttonImage: 'calendar.gif',
    buttonText: 'Click to select a date',
    duration:"fast",
    changeMonth: true,
    changeYear: true,
    dateFormat: 'dd/mm/yy',
    constrainInput: true,
    yearRange: '-120:0',
    maxDate: 0,
    buttonImageOnly: true
});

我需要有关两个日期选择器对象的帮助,非常感谢任何帮助.

I need help with both datepicker object, any help would be very much appreciated.

推荐答案

我解决了我的问题,即 jquery 库有点过时了.

I fixed my problem which it was the jquery libraries were a bit out date.

如果有人对此解决方案感兴趣,请查看此处.

If anyone interested on this solution please check here.

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

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