我知道有很多与此相关的问题,但我找不到有帮助的信息...我只需要在我的脚本中解决这个问题,有人可以帮助我吗?
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();
我在第 8 行遇到这个错误:
return twoDates.inputDate.getTime() < twoDates.todaysDate.getTime();
谢谢
最佳答案
创建Date
对象而不是字符串,更改此行
inputDate: $('#employmentDate').val(),
至
inputDate: new Date($('#employmentDate').val()),
关于javascript - 无法读取未定义错误的属性 'getTime',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42780366/