HTML
生产日期:
<input id="comDate" name="comDate" value="<fmt:formatDate pattern="yyyy-MM-dd" value="${commodity.comDate}"/>" type="date" required="" max=""/>
过期日期:
<input id="outDate" name="outDate" value="<fmt:formatDate pattern="yyyy-MM-dd" value="${commodity.outDate}"/>" type="date" required="" min=""/>
<script>
$("#comDate").on("click", function () {
var date_now = new Date();
var year = date_now.getFullYear();
var month = date_now.getMonth() + 1 < 10 ? "0" + (date_now.getMonth() + 1) : (date_now.getMonth() + 1);
var date = date_now.getDate() < 10 ? "0" + date_now.getDate() : date_now.getDate();
$("#comDate").attr("max", year + "-" + month + "-" + date);
document.getElementById('outDate').value = "";
})
$("#outDate").on("click", function () {
var oldDate = document.getElementById('comDate').value;
$("#outDate").attr("min", oldDate);
})
</script>