3

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....

1
  • 1
    Exactly how is it not working? Is there an error message? How is the result different from what you expect? Commented Dec 3, 2010 at 10:53

1 Answer 1

7

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('');
                }
            });

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.