简体   繁体   English

如何设置jQuery日期选择器的最大年份限制为当年之前的3年

[英]how to set the jQuery date picker max year limit is 3 years before of current year

I need to display the 100 yrs from the current date but max years is current year - 3 eg need a years from (2017)-100. 我需要显示从当前日期开始的100年,但是最大年份是当前年份-3例如需要从(2017)-100开始的年份。 so 1917-2017(current yr) but max years is must be 2014(subtract from current year). 因此1917-2017(当年),但最大年份必须是2014(从当年减去)。 my code is: 我的代码是:

<input type="text" ng-model="formData.cspNomineeDob" 
  placeholder="{{'com.inspirenetz.webapp.merchant.customer_form_nominee_dob_place_holder' | translate }}" 
  ng-change="age(formData.cspNomineeDob)" data-year-range="c-100" data-max-date="0" in-date-picker
/>
thisyear = new Date().getFullYear()      // Get the year as yyyy

Then set your minDate and maxDate accordingly when you configure the widget 然后在配置小部件时相应地设置minDate和maxDate

[...]

$scope.options = {
    minDate: new Date(yourdates),
    maxDate: new Date(ofchoice)
};

[...]

as per https://angular-ui.github.io/bootstrap/#!#datepicker . 根据https://angular-ui.github.io/bootstrap/#!#datepicker

You might be looking for: 您可能正在寻找:

https://stackoverflow.com/a/14685967/1971378 https://stackoverflow.com/a/14685967/1971378

Reproduced from there: 转载自:

$( "#datepicker" ).datepicker( { minDate: -0, maxDate: new Date(2013, 1,18) }); $(“ #datepicker”).datepicker({minDate:-0,maxDate:new Date(2013,1,18)});

It uses minDate and maxDate options in the datepicker's configuration. 它在datepicker的配置中使用minDate和maxDate选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM