Skip to content Skip to sidebar Skip to footer

Jquery Date Comparison

Hi iam using the following code for comparing the entered date with current date... But it is not working... $('#<%=txtOrderDate.ClientID%>').change(function() {

Solution 1:

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


Post a Comment for "Jquery Date Comparison"