This article analyzes the javascript input date greater than or equal to the current date verification code through an example, and shares it with everyone for your reference. The details are as follows:
<script> $(function () { var d = new Date(); var strDate = getDateStr(d); $("#beginTime").val(strDate); $("#endTime").val(strDate); //$("#beginTime").val("2015-10-10"); $("#beginTime").change(function () { var d2 = new Date($("#beginTime").val()); if (d2 < d) { alert("填写的动工日期必须大于当前日期."); $("#beginTime").val(strDate); } }); $("#endTime").change(function () { var d2 = new Date($("#beginTime").val()); var d3 = new Date($("#endTime").val()); if (d3< d2) { alert("填写的完工日期不能小于动工日期."); $("#endTime").val(getDateStr(d2)); } }); }); function getDateStr(date) { var month = date.getMonth() + 1; var strDate = date.getFullYear() + '-' + month + '-' + date.getDate(); return strDate; } </script>
I hope this article will be helpful to everyone in JavaScript programming.