jQuery DateJs,是否有完整日期的验证? [英] Jquery DateJs, is there validation for full date?

查看:80
本文介绍了jQuery DateJs,是否有完整日期的验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是了解date js的功能,它很棒!!! 因为我是新手,所以我想知道是否有针对各种类型的完整日期的一般验证. 例如.

I just find out about the power of date js, And its great!!! As I am a newbie I was wondering if there is any kind of general validitation for different types of full dates. eg.

var d1 = Date.parse('2000-10-18, 10:06 AM');
alert(d1.toString('HH:mm'));

如果日期为('200-10-18,10:06 AM'),那么当然不喜欢它.

If date is ('200-10-18, 10:06 AM'), of course it doesn't like it.

所以我的问题是,是否有任何快速的方法可以验证整个日期,而不是一个一个地验证.

So my question is if there is any quick way to validate the full date, rather than having to validate one by one.

谢谢.

推荐答案

在这里,我再次回答您的问题.

Here I am answering your question again.

要验证日期,您只需致电:

To validate a date, you can simply call:

var d1 = "200-10-18, 10:06 AM";
Date.validateDay(d1); 

它会告诉您日期是否有效.

And it will tell you if the date is valid.

编辑

或者,您可以简单地执行以下操作:

Or, you can simply do this:

var d = Date.parseExact("2008-03-08", "yyyy-MM-dd"); 
if (d !== null) { 
     alert('Date = ' + d.toString('MMMM dd, yyyy')); 
} 

如果日期无效,则使用parseExact将返回null.

Using parseExact will return null in case the date is not valid.

这篇关于jQuery DateJs,是否有完整日期的验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆