我有一个表格,我从日期到日期有2个日期时间选择器,我的要求是如果选择的起始日期是17-4-2014,那么到目前为止也必须在同一天。它不应该允许18或任何其他日期。此外,它应该验证时间不能少于时间。请帮助我使用javascript修复此问题
答案 0 :(得分:0)
尝试这样的事情
$(function(){
$("#datepicker1").datepicker(
{dateFormat: "dd-M-yy",
changeMonth: true,
changeYear: true,
minDate: '-60Y', maxDate: '+0Y',
yearRange: '-60:+20',
showOn: "button",
buttonImage: '/cpf/images/datepicker.gif',
buttonImageOnly: true
}
);
});
$(function(){
$("#datepicker2").datepicker(
{dateFormat: "dd-M-yy",
changeMonth: true,
changeYear: true,
minDate: '-60Y', maxDate: '+0Y',
yearRange: '-60:+20',
showOn: "button",
buttonImage: '/cpf/images/datepicker.gif',
buttonImageOnly: true
}
);
});
<TD align="right" width="10%"><strong>Service Date From</strong></TD>
<TD width="16%"><input id="datepicker1" name="check_in_from" class="input_style4" type="text" readonly value="{$form.check_in_from|date_format:" %d-%b-%Y"}" style="width: 160px;"> <img src="images/clear.gif" alt="clear" title="clear" onclick="clear1('datepicker1')"></td>
<TD align="right" width="11%"><strong>Service Date To</strong></TD>
<TD width="16%"><input id="datepicker2" name="check_in_to" class="input_style4" type="text" readonly value="{$form.check_in_to|date_format:" %d-%b-%Y"}" style="width: 160px;"> <img src="images/clear.gif" alt="clear" title="clear" onclick="clear1('datepicker2')"></TD>