This article analyzes the JavaScript input date is more than equal to the current date validation code, share for everyone to refer to, specific 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 ("The commencement date to be completed must be greater than the current date.");
$ ("#beginTime"). Val (strdate);
}
);
$ ("#endTime"). Change (function () {
var d2 = new Date ($ ("#beginTime"). Val ());
var d3 = new Date ($ ("#endTime"). Val ());
if (d3< D2) {
alert ("The completed date cannot be less than the commencement date.");
$ ("#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 help you with JavaScript programming.