我使用jEditable和jQuery DatePicker一起使用。我正在嘗試對日期範圍進行驗證。例如,如果在startDate
字段中選擇了2010年6月1日,則用戶不能在endDate
字段中選擇2010年6月1日之前的日期,反之亦然。如何訪問jEditable DatePicker選項(onSelect,minDate,maxDate)
除驗證部分外,所有其他代碼都可以使用。我的理解是jQuery-ui DatePicker的完整版本包含在jEditable版本中,但我不知道如何使用它。
這是我使用的DatePicker:DatePicker的插件https://github.com/qertoip/jeditable-datepicker/tree/master/src
樣品展示:http://thesingularity.pl/jeditable-datepicker-demo/
我的腳本
$('#startDate').editable('AppUpdateServlet',{
indicator : '<img src="images/indicator.gif">',
type: 'datepicker',
datepicker: {
dateFormat: 'dd/mm/yy',
//minDate: '+1w' (this is working)
onSelect: function() {
//the alert is working
//alert("working");
//not working
$('#endDate').datepicker('option', {minDate: $(this).datepicker('getDate')});
}
}
});
$('#endDate').editable('AppUpdateServlet',{
indicator : '<img src="images/indicator.gif">',
type: 'datepicker',
datepicker: {
dateFormat: 'dd/mm/yy',
onSelect: function() {
//not working
$('#startDate').datepicker('option', {minDate: $(this).datepicker('getDate')});
}
}
});
HTML代碼段
<span id="startDate">
<%=test.getStartDate()%>
</span>
<span id="endDate">
<%=test.getEndDate()%>
</span>
你檢查你的'#startDate'和'#endDate'選擇匹配什麼在DOM結束了? –
我該如何檢查?我認爲問題在於增加了jEditable。因此,可能會有額外的參數輸入,所以$('#startDate')。datepicker('option',{minDate:$(this).datepicker('getDate')});不起作用 – newtodatatables
使用一個DOM檢查器,如Chrome(「檢查元素」)或Firebug for Firefox,它應該告訴你如何識別文本輸入,我不認爲數據夾實際上是連接到'# startDate'和'#endDate'跨度。 –