0

I'm attempting to write some jquery from the first time and I'm using the validatation plugin.

as you can see in my code, i just want to print out the value of the Date object.

$.validator.addMethod(
        "testDate",
        function(value, element)
        {
            var currentDate = new Date();
            var dateObj = new Date(value);
            if(element == "dob")
            {
                if(dateObj > currentDate)
                {
                    console.log(currentDate);
                    console.log(dateObj);
                    return false;
                }
            }
            else if(element == "scheduledExamDate")
            {
                if((dateObj.getFullYear() > currentDate.getFullYear()+1)||(dateObj.getTime() < currentDate.getTime()))
                {
                    return false;
                }
            }
        });
4

1 回答 1

1

Use Date.toString() (like: console.log(currentDate.toString()))

See this article on MDN.

于 2012-06-07T17:12:55.310 回答