最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jQuery Date Picker Pick Year First and then Month - Stack Overflow

programmeradmin5浏览0评论

What changes are needed to show the Years dropdown first and then the months dropdown as second field in jQuery so users can select which year they are born and then select the month in that year. We still want to restrict that calendar cannot display date greater than today.

If user selects 2011, they should not be allowed to select date greater than today.

What changes are needed to show the Years dropdown first and then the months dropdown as second field in jQuery so users can select which year they are born and then select the month in that year. We still want to restrict that calendar cannot display date greater than today.

If user selects 2011, they should not be allowed to select date greater than today.

Share Improve this question edited Dec 20, 2011 at 7:06 bAN 13.8k17 gold badges62 silver badges97 bronze badges asked Nov 28, 2011 at 16:49 KBGKBG 511 silver badge7 bronze badges 2
  • Why don't you use selects instead? – v42 Commented Nov 28, 2011 at 17:08
  • Right now calendar object has select fields. But it has month first. Since month is first box it is not showing dec since year is default to 2011.this is nov so users are confused why dec is not showing up. If they change year to 2010 then all months are shown. Hope I explained it. – KBG Commented Nov 29, 2011 at 2:50
Add a ment  | 

2 Answers 2

Reset to default 15

I was looking for this also and got here but no solution so I get into jquery-ui.custom.min.js and found the an option. Its as below. Hope it helps although its a bit late..

$( "#datepicker_id" ).datepicker({
    showOn: "button",
    buttonImage: "images/calendar.png",
    buttonImageOnly: true,
    dateFormat:'mm-dd-yy',
    changeYear: true,
    changeMonth: true,
    showMonthAfterYear: true, //this is what you are looking for
    maxDate:0
});

But if you found that already you should have posted it here :)

For this simple use below line:

startView: 2

And add below line to prevent to select date greater than today:

endDate: new Date(),
发布评论

评论列表(0)

  1. 暂无评论