วันที่เริ่มต้น var StartDateTextBox = $('#time_start');
วันที่สิ้นสุด var EndDateTextBox = $('#time_end');
วันที่เรียนเริ่มต้น var StustartDateTextBox = $('#time_stu_start');
วันที่เรียนสิ้นสุด var StuendDateTextBox = $('#time_stu_end');
ผมไม่รู้จะเอาเงื่อนไขใส่ไว้ตรงไหน
Code (JavaScript)
var testEndDate = EndDateTextBox.datetimepicker('getDate');
var testtEndDate = StuendDateTextBox.datetimepicker('getDate');
if (testEndDate > testtEndDate)
EndDateTextBox.datetimepicker('setDate', testtEndDate);
Code (JavaScript)
$(function(){
var StartDateTextBox = $('#time_start');
var EndDateTextBox = $('#time_end');
var StustartDateTextBox = $('#time_stu_start');
var StuendDateTextBox = $('#time_stu_end');
StartDateTextBox.datepicker({
dateFormat: 'dd-mm-yy',
onClose: function(dateText, inst) {
if (EndDateTextBox.val() != '') {
var testStartDate = StartDateTextBox.datetimepicker('getDate');
var testEndDate = EndDateTextBox.datetimepicker('getDate');
if (testStartDate > testEndDate)
EndDateTextBox.datetimepicker('setDate', testStartDate);
}
else {
EndDateTextBox.val(dateText);
}
},
onSelect: function (selectedDateTime){
EndDateTextBox.datetimepicker('option', 'minDate', StartDateTextBox.datetimepicker('getDate') );
}
});
EndDateTextBox.datepicker({
dateFormat: 'dd-mm-yy',
onClose: function(dateText, inst) {
if (StartDateTextBox.val() != '') {
var testStartDate = StartDateTextBox.datetimepicker('getDate');
var testEndDate = EndDateTextBox.datetimepicker('getDate');
if (testStartDate > testEndDate)
StartDateTextBox.datetimepicker('setDate', testEndDate);
}
else {
StartDateTextBox.val(dateText);
}
},
onSelect: function (selectedDateTime){
StartDateTextBox.datetimepicker('option', 'maxDate', EndDateTextBox.datetimepicker('getDate') );
}
});
StustartDateTextBox.datepicker({
dateFormat: 'dd-mm-yy',
onClose: function(dateText, inst) {
if (StuendDateTextBox.val() != '') {
var testtStartDate = StustartDateTextBox.datetimepicker('getDate');
var testtEndDate = StuendDateTextBox.datetimepicker('getDate');
if (testtStartDate > testtEndDate)
StuendDateTextBox.datetimepicker('setDate', testtStartDate);
}
else {
StuendDateTextBox.val(dateText);
}
},
onSelect: function (selectedDateTime){
StuendDateTextBox.datetimepicker('option', 'minDate', StustartDateTextBox.datetimepicker('getDate') );
}
});
StuendDateTextBox.datepicker({
dateFormat: 'dd-mm-yy',
onClose: function(dateText, inst) {
if (StustartDateTextBox.val() != '') {
var testtStartDate = StustartDateTextBox.datetimepicker('getDate');
var testtEndDate = StuendDateTextBox.datetimepicker('getDate');
if (testtStartDate > testtEndDate)
StustartDateTextBox.datetimepicker('setDate', testtEndDate);
}
else {
StustartDateTextBox.val(dateText);
}
},
onSelect: function (selectedDateTime){
StustartDateTextBox.datetimepicker('option', 'maxDate', StuendDateTextBox.datetimepicker('getDate') );
}
});
});