Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想使用 jQuery Validation 插件验证输入(出生日期),但它必须采用“dd/mm/yyyy”格式,并且当年份超过 2002 年时也不能验证。
因此,当日期格式为“dd/mm/yyyy”且年份超过“2002”时,日期有效
我找到了答案 :D 就是这样。谢谢大家
$.validator.addMethod("birth", function (value, element) { var year = value.split('/'); if ( value.match(/^\d\d?\/\d\d?\/\d\d\d\d$/) && parseInt(year[2]) <= 2002 ) return true; else return false; });