JavaScript - 验证日期 [英] JavaScript - Validate Date
问题描述
我认为有一些类似isNaN的东西,但我看不到任何东西。 JavaScript是否可以验证日期?
验证日期?
否。
有没有这样的功能?
否。
您将需要编写自己的验证函数来解析日期格式(请注意正则表达式),然后确定它是否在您的特定标准中有效。
I have an HTML text field. I want to validate via JavaScript that the value entered is a valid date in the form of "MM/DD/YY" or "MM/D/YY" or "MM/DD/YYYY" or "MM/D/YYYY". Is there a function that does this?
I sort of assumed there was something like isNaN but I don't see anything. Is it true that JavaScript can't validate dates?
Is it true that JavaScript can't validate dates?
No.
Is there a function that does this?
No.
You will need to write your own validation function to parse the date format (regex comes to mind) and then determine if it is valid within your specific criteria.
这篇关于JavaScript - 验证日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!