我有下面的Java腳本代碼,將驗證日期範圍...當用戶輸入今天的日期或任何未來的日期我已經將IsValid設置爲true,然後將執行保存操作....JavaScript日期驗證不適用於今天的日期
爲此我寫了下面的代碼..
function Save(e) {
var popupNotification = $("#popupNotification").data("kendoNotification");
var container = e.container;
var model = e.model;
var isValid = true;
var compareDate = e.model.DeliveryDate;
alert(compareDate);
var todayDate = new Date();
var compareDateModified = new Date(compareDate)
alert(compareDateModified);
if (compareDateModified > todayDate || compareDateModified === todayDate) {
isValid = true;
}
else
isValid = false;
e.preventDefault();
if (isValid == false)
{
popupNotification.show("Delivery Date should be today date or Greater", "error");
}
$('#Previous').show();
$('#Next').show();
}
其工作正常,當我給將來的日期,但它不工作爲今天的日期。我還需要檢查今天的日期。當我嘗試輸入今天的日期時,我無法找出錯誤提示。
非常感謝它現在的工作..... –