此代码不起作用,当我尝试比较它不起作用的日期 [英] This Code Is Not Working And When I Try To Compare Date It Is Not Working

查看:100
本文介绍了此代码不起作用,当我尝试比较它不起作用的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

frmdate = document.getElementById("txt_fromdate").value;
          todt = document.getElementById("txt_todate").value;
var date1 = new Date(frmdate);
         var date2 = new Date(todt);
         var date3 = new Date();
         var date4 = date3.getMonth() + "/" + date3.getDay() + "/" + date3.getYear();
         var currentDate = new Date(date4);
         if (date2 > currentDate) {
             alert("To date can not be greater than current date");
             return false;
         }

推荐答案

熟悉 JavaScript中的日期对象 [ ^ ]并为每个日期构造一个,并使用普通比较运算符进行比较。
Get familiar with the Date object in JavaScript[^] and construct one for each date and compare them using normal comparison operators.


这篇关于此代码不起作用,当我尝试比较它不起作用的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆