我有一個jsp頁面,用戶選擇兩個日期。我需要驗證此日期以確保第一個日期不低於今天的日期。這是我使用的腳本:JSP日期驗證
var todaysDate = new Date();
if(document.frm.rentedOnDate.value < todaysDate)
{
alert("Rented date should not be before today");
document.frm.bank.focus();
return false;
}
if(document.frm.rentedOnDate.value> document.frm.returnDate.value)
{
alert("Return date should be after rented date");
document.frm.bank.focus();
return false;
}
這些日期選擇字段:
<p>Select Rental Date: <input type="date" name="rentedOnDate"> </p>
<p>Select Return Date: <input type="date" name="returnDate"> </p>
當用戶輸入這是租來的日期,但第一前返回日期第二個腳本功能的工作原理功能不起作用。任何想法爲什麼?
我用這樣:var D1 =新的日期(document.frm.rentedOnDate)和它的工作!感謝 –