使用changeYear选项时,可以使jQuery datepicker显示更多年吗? [英] Can I make the jQuery datepicker display more year when using the changeYear option?

查看:176
本文介绍了使用changeYear选项时,可以使jQuery datepicker显示更多年吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个应用程序中使用jQuery datepicker,除其他事项外,该应用程序将用于插入和更新员工的出生日期.我发现必须多次单击才能到达70年代和80年代的时代,这是许多员工出生的几十年.有没有办法以更少的点击次数来进入这些更远的"岁月? 这就是我的日期选择器的样子

I am using the jQuery datepicker in an application which will be used, among other things, to insert and update birth dates of employees. I find it cumbersome to have to click several times in order to get to the 70's and 80', decades in which many employees are born in. Is there a way to access these 'further' years in less clicks? This is what my datepicker looks like

$("#DateOpened").datepicker({
    dateFormat: "mm/dd/yy",
    maxDate: "+0D",
    showAnim: 'slide',
    changeMonth: true,
    changeYear: true,
    'setDate': new Date(),
    onClose: function (selectedDate) {
        $("#DateClosed").datepicker("option", "minDate", selectedDate);
    }
});

推荐答案

使用yearRange选项增加年份下拉列表的大小.

Use the yearRange option to increase the size of the year drop-down.

yearRange: "c-30:+0"

允许一次单击选择1983年之后的年份,而两次单击选择70年份.

will allow selecting a year after 1983 in one click, and the 70's in 2 clicks.

FIDDLE

但是,这不是一个好的UI.当用户第一次单击菜单时,通过选择一个旧年份然后再次单击菜单,他们可以追溯到30年前并不明显.您可以使用c-100:+0允许菜单包含100年,希望对于大多数用户来说足够了.

However, this isn't a good UI. When the user first clicks on the menu, it's not obvious that they can go back more than 30 years by first selecting an old year and then clicking on the menu again. You can use c-100:+0 to allow the menu to contain 100 years, hopefully this wil be enough for most users.

这篇关于使用changeYear选项时,可以使jQuery datepicker显示更多年吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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