Reputation: 754
I know there were a lot of questions related to this, but I couldn't find information that would help... I just need to solve this problem in my script, does anyone could help me with that?
function dateValidation() {
this.validateDate = function() {
var twoDates = {
inputDate: $('#employmentDate').val(),
todaysDate: new Date()
}
return twoDates.inputDate.getTime() < twoDates.todaysDate.getTime();
}
}
var validation = new dateValidation();
validation.validateDate();
This error I'm getting on the line 8:
return twoDates.inputDate.getTime() < twoDates.todaysDate.getTime();
Thank you
Upvotes: 2
Views: 8297
Reputation: 34914
Create Date
object instead string, Change this line
inputDate: $('#employmentDate').val(),
To
inputDate: new Date($('#employmentDate').val()),
Upvotes: 2