2017-03-10 30 views
-2

關於Datepicker?

$(document).ready(

    /* This is the function that will get executed after the DOM is fully loaded */ 
    function() { 
    $(".datepicker").datepicker({ 
     changeMonth: true, //this option for allowing user to select month 
     changeYear: true, //this option for allowing user to select from year range 
     dateFormat: "dd-mm-yy" //this option is for display in dd-mm-yy format 
    }); 
    } 
); 

這是我的輸入代碼:

<label>Date Of Birth:*</label> 
<input type="text" id="datepicker" name="datepicker" class="form-control datepicker"> 

從這個代碼,我沒有得到我那麼,怎樣才能讓過去的幾年中2007年之前的十年?

回答

0

可以使用yearRange選項設置可以選擇的範圍:

硬編碼:yearRange: "2000:2020"

相對:yearRange: "-100:+0"

默認值爲:今年 - 10:今年+ 10 =>此就是爲什麼你可以從2007年

0

只能選擇儘量

yearRange:"minYear:maxYear", 

yearRange:"-yearFromCurrentYear:+yearFromCurrentYear" 

代碼示例:

$(document).ready(
    /* This is the function that will get executed after the DOM is fully loaded */ 
    function() { 
    $(".datepicker").datepicker({ 
     changeMonth: true, //this option for allowing user to select month 
     changeYear: true, //this option for allowing user to select from year range 
     yearRange: "1900:2100", 
     dateFormat: "dd-mm-yy" //this option is for display in dd-mm-yy format 
    }); 
    } 
); 

小提琴推移Here