2016-05-13 93 views
-2

有人可以幫我糾正這段代碼。我想選擇1990年至2000年之間的日期,而不允許選擇其他日期,例如未來的日期。我想要這個日期選擇器從1990年到2000年之間的幾年選擇日期

<script> 
$(document).ready(function(){ 
    $("#EmpBirthdate").datepicker({ 
     dateFormat: 'yy-mm-dd', 
     showOn: "button", 
     buttonImage: "images/calendar.gif", 
     buttonImageOnly: true, 
     changeMonth: true, 
     changeYear: true, 
     yearRange: "-30" 
    }); 
}); 
</script> 
+2

你只需要閱讀文檔:https://jqueryui.com/datepicker/#min-max –

回答

0

您可以使用最小值最大值屬性

Min Max

$("#datepicker").datepicker({ minDate: value1, maxDate: value2 }); 
1
$(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