Jquery日期比较 [英] Jquery date comparison

查看:65
本文介绍了Jquery日期比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好iam使用以下代码将输入的日期与当前日期进行比较......但它不起作用...

Hi iam using the following code for comparing the entered date with current date... But it is not working...

$('#<%=txtOrderDate.ClientID%>').change(function() {
            var date = $('#<%=txtOrderDate.ClientID%>').val();
            var arrDate = date.split("/");
            var today = new Date();
            var useDate = new Date(arrDate[2], arrDate[1] - 1, arrDate[0]);
            if (useDate > today) {
                alert('Please Enter the correctDate');
                $('#<%=txtOrderDate.ClientID%>').val('');
            }
        });

如果有人知道的话,请帮帮我......谢谢....

Help me if anybody knows it... Advance thanks....

推荐答案

我试图复制你的代码,这可以在我的机器上运行

i tried to copy your code and this works on my machine

            $('#txtbox').change(function() {
                var date = $(this).val();
                var arrDate = date.split("/");
                var today = new Date();
                useDate = new Date(arrDate[2], arrDate[1] -1, arrDate[0]);

                if (useDate > today) {
                    alert('Please Enter the correctDate');
                    $(this).val('');
                }
            });

我从useDate中删除了var,并注意新的Dateparameter是(y,m,d )。

i removed the var from the useDate, and take note that new Dateparameter is (y,m,d).

这篇关于Jquery日期比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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