$("#s_shipDate_from").datepicker({
dateFormat : "yy-mm-dd",
showButtonPanel: false,
showOn: "button",
buttonImage: "images/Cal.gif",
buttonImageOnly: true,
onSelect: function (dateText, inst) {
if($('#s_shipDate_to').val()!="")
{
var fromDate = new Date(dateText);
var toDate = new Date($('#s_shipDate_to').val());
$('#s_shipDate_to').datepicker("option", 'minDate', fromDate);
if(toDate<fromDate)
{
alert("'TO' date must be more than 'FROM' date.");
$('#s_shipDate_to').datepicker("setDate", fromDate);
}
}
}
})
$("#s_shipDate_to").datepicker({
dateFormat : "yy-mm-dd",
showButtonPanel: false,
showOn: "button",
buttonImage: "images/Cal.gif",
buttonImageOnly: true,
beforeShow : function (input, inst) {
if($('#s_shipDate_from').val()!="")
{
var fromDate = new Date($('#s_shipDate_from').val());
$('#s_shipDate_to').datepicker("option", 'minDate', fromDate);
}
},
onSelect: function (dateText, inst) {
if($('#s_shipDate_from').val()!="")
{
var fromDate = new Date($('#s_shipDate_from').val());
var toDate = new Date(dateText);
if(toDate<fromDate)
{
alert("'TO' date must be more than 'FROM' date.");
$('#s_shipDate_to').datepicker("setDate", fromDate);
}
}
}
})
我有日期字段From
,To
使用 jquery-ui datepicker。我编写了上面的代码,因此To
日期不能超过From
日期,它在 FF/chrome 中效果很好,但在 IE(8) 中不起作用。有任何想法吗?