我的html代码中有录取日期和出院日期。现在我可以验证日期,使得出院日期总是大于入院日期吗?如果有人愿意帮助我,我将非常感激。
以下是相同的html和JavaScript代码:
$(document).ready(function() {
$("#txtFromDate").datepicker({
numberOfMonths: 2,
onSelect: function(selected) {
$("#txtToDate").datepicker("option", "minDate", selected)
}
});
$("#txtToDate").datepicker({
numberOfMonths: 2,
onSelect: function(selected) {
$("#txtFromDate").datepicker("option", "maxDate", selected)
}
});
});
HTML:
Admission Date:<input type="date" name="admission_dt" id="txtFromDate" required/>
Discharge Date:<input type="date" name="discharge_dt" id="txtToDate" required/>
答案 0 :(得分:0)
const admissionDate = new Date('2016-01-01');
const dischargeDate = new Date('2017-01-01');
function isDischargeGreaterThanAdmission(admissionDate, dischargeDate){
return dischargeDate > admissionDate;
}
console.log(isDischargeGreaterThanAdmission(admissionDate, dischargeDate));
&#13;