2012-11-28 169 views
0

我正在使用jquery datepicker http://jqueryui.com/datepicker/#default。 我必須輸入像和迄今爲止的字段。 到目前爲止,起始日期應該作爲日期選擇器中的最小值出現。jquery datepicker迄今

<input class="user-reg-input fl" type="text" name="Duration_From[]" id="Duration_From1" value="" maxlength="25" style="width:117px;" /> 
<input class="user-reg-input fl" type="text" name="Duration_To[]" id="Duration_To1" value="" maxlength="25" style="width:117px;" /> 
+0

hook @'.change'並修改對應的範圍 –

+0

請問您可以更具體的 –

+0

如果用戶從日期選擇如12-09-1991那麼到目前爲止必須提前10年 –

回答

0

您可以嘗試this

<input class="user-reg-input fl dt-from" type="text" name="Duration_From[]" id="Duration_From1" value="" maxlength="25" style="width:117px;" /> 
<input class="user-reg-input fl dt-to" type="text" name="Duration_To[]" id="Duration_To1" value="" maxlength="25" style="width:117px;" /> 

$('.user-reg-input').datepicker(); 

$('.user-reg-input.dt-from').on('change', function(el){ 
    console.log($(el.currentTarget).next()) 
    $(el.currentTarget).next().datepicker('option', 'minDate', $(el.currentTarget).val()) 
}) 
0
$(function() { 
$("#Duration_From1").datepicker({ 
    showOn: "both", 
    buttonImage: CONTEXT_PATH + "/images/icon_calendar.png", 
    buttonImageOnly: true, 
    minDate: new Date(), 
    dateFormat: 'dd/mm/yy', 
    onSelect: function(dateText,inst){ 
     $("#Duration_To1").datepicker("option","minDate",new Date(inst.currentYear,inst.currentMonth,parseInt(inst.currentDay))); 
     $("#Duration_To1").val(dateText); 
    } 
}); 
}); 

這是我的項目工作代碼段。