在jQuery datepicker中设置最小日期 [英] setting min date in jquery datepicker

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

问题描述

我想将我的jquery datepicker中的最小日期设置为(1999-10-25),所以我尝试了下面的代码,它不起作用.

Hi i want to set min date in my jquery datepicker to (1999-10-25) so i tried the below code its not working.

$(function () {
    $('#datepicker').datepicker({
        dateFormat: 'yy-mm-dd',
        showButtonPanel: true,
        changeMonth: true,
        changeYear: true,
        showOn: "button",
        buttonImage: "images/calendar.gif",
        buttonImageOnly: true,
        minDate: new Date(1999, 10 - 1, 25),
        maxDate: '+30Y',
        inline: true
    });
});

**如果我将最小年份更改为2002年以上,它将可以正常工作,但是如果我指定的最小年份小于2002年(如上述eexample 1999年),则最多只能显示2002年.有人可以帮助我.我正在使用jquery-1.7.1.min.js和jquery-ui-1.8.18.custom.min.js.

** if i change the min year to above 2002 than it will work fine but if i specify min year less than 2002{like above eexample 1999} it will show only up to 2002.can someone help me. i am using jquery-1.7.1.min.js and jquery-ui-1.8.18.custom.min.js.

推荐答案

$(function () {
    $('#datepicker').datepicker({
        dateFormat: 'yy-mm-dd',
        showButtonPanel: true,
        changeMonth: true,
        changeYear: true,
yearRange: '1999:2012',
        showOn: "button",
        buttonImage: "images/calendar.gif",
        buttonImageOnly: true,
        minDate: new Date(1999, 10 - 1, 25),
        maxDate: '+30Y',
        inline: true
    });
});

仅添加了年份范围选项.应该可以解决问题了

Just added year range option. It should solve the problem

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

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