Date.parse()在IE 8中不起作用 [英] Date.parse() doesn't work in IE 8
本文介绍了Date.parse()在IE 8中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
简单功能 Date.parse()
在 Internet Explorer 8 中不能正常工作。
我正在使用 Date.parse()
以格式MM / DD / YYYY
验证日期。
Simple function Date.parse()
not working well in Internet Explorer 8.
I am using Date.parse()
to validate date in format "MM/DD/YYYY"
.
-
_。isNaN(Date.parse(99/99/9999))
returntrue
- 日期无效 -
_。isNaN(Date.parse(01/01/1990))
returnfalse
- 日期有效
_.isNaN(Date.parse("99/99/9999"))
returntrue
- date is invalid_.isNaN(Date.parse("01/01/1990"))
returnfalse
- date is valid
但是现在我试过我的JavaScript在IE 8和我很困惑。
But now I tried my JavaScript in IE 8 and I'm confused.
-
88/88/8888
- 在这一天,日期无效 -
13/35/2012
- 无效日期
但日期.parse(13/35/2012)
仅在IE中解析此日期,不返回NaN
。
"88/88/8888"
- for this date all working well - date is invalid."13/35/2012"
- invalid date butDate.parse("13/35/2012")
parse this date in IE only and don't returnNaN
.
任何想法?
推荐答案
我使用我的方法进行日期验证
I used my method for date validation
var isValidDate = function(dateAsString)
{
var parsedDate = Date.parse(dateAsString);
if (_.isNaN(parsedDate) || !_.isEqual(new Date(parsedDate).format("mm/dd/yyyy"), dateAsString))
{
return false
}
return true
}
这篇关于Date.parse()在IE 8中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文