我想要一个正则表达式来验证17/04/2012之后的日期请帮我修补一下?没有使用jQuery datepicker [英] I want a regular expression to validate date after 17/04/2012 please help me frnds ? with out using jQuery datepicker

查看:49
本文介绍了我想要一个正则表达式来验证17/04/2012之后的日期请帮我修补一下?没有使用jQuery datepicker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个正则表达式来验证17/04/2012之后的日期请帮助我的朋友

ia在2012年1月1日之后有正常exp的代码

是/ ^(0?[1-9] | [12] \d | 3 [01])\ /(0?[1-9] | 1 [012])\ /(201 [2-9] ] | 20 [2-9] \d | 2 [1-9] \\\)$ /

I want a regular expression to validate date after 17/04/2012 please help me friends
i a have code with regular exp for after 01/01/2012
that is /^(0?[1-9]|[12]\d|3[01])\/(0?[1-9]|1[012])\/(201[2-9]|20[2-9]\d|2[1-9]\d\d)$/

推荐答案

/


对于每一个结构良好的数据(如日期)使用Regex并不好,因为这可能已经为您完成了。更好的想法是:尝试将数据解析为所需的结构,看看它是否成功。它为您提供了真正的终极验证,并且作为一个重要的奖励,结构化对象本身。



如果是日期和Javascript,使用的好处是
This is not good to use Regex with every piece of well-structured data, such as date, because this might be already done for you. The better idea is: try to parse data to required structure and see if it succeeds or not. It gives you the really ultimate validation, and, as a big bonus, the structured object itself.

In case of date and Javascript, good thing to use is


.datepicker.parseDate(格式,值,设置)

http://api.jqueryui.com/datepicker [ ^ ]。



您可以将字符串解析为您自己定义的日期格式。使用此方法,您不必使用 datepicker 控件本身。但是,为什么不呢?使用它将是一个好主意。如果你这样做,你可能永远不需要进行解析。 :-)



-SA
.datepicker.parseDate(format, value, settings):
http://api.jqueryui.com/datepicker[^].

You can parse the string to the date format you define yourself. And with this method, you don't have to use the datepicker control itself. However, why not? Using it would be a good idea. If you do it, you may never need to do the parsing per se. :-)

—SA


这篇关于我想要一个正则表达式来验证17/04/2012之后的日期请帮我修补一下?没有使用jQuery datepicker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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