[英]Validating a form containing a date and a time field that together must describe a date and time in the future
I have a form containing a lot of fields that all have some sort of validation. 我有一个包含很多字段的表单,这些字段都有某种形式的验证。 Two fields however are special: a date field and a time field. 但是,有两个特殊的字段:日期字段和时间字段。 Their validation states that their combined date/time value is a timestamp somewhere in the future. 他们的验证表明,它们组合的日期/时间值是将来某个地方的时间戳。 I use the jQuery validation plugin plus its extra functions to do the validation. 我使用jQuery验证插件及其额外功能来进行验证。 Check out this fiddle to see a trimmed down version of what I have: 看看这个小提琴,看看我拥有的精简版:
http://jsfiddle.net/2df9h/4/ http://jsfiddle.net/2df9h/4/
I have a couple of problems: 我有几个问题:
I have tried to validate the other field using the technique described here : $(.. selector for the two fields...).valid()
, but due to a bug described in this comment in that post the other fields will no be validated anymore when I do that. 我试图使用此处描述的技术来验证另一个字段: $(.. selector for the two fields...).valid()
,但是由于该评论中描述的错误,其他字段将不会当我这样做时,已经验证了。 I'm pretty much stuck... Any idea? 我几乎被困住了...知道吗?
You can force (or clear) an error on any field programatically with the method .showErrors(errors)
(see documentation ). 您可以使用.showErrors(errors)
方法.showErrors(errors)
编程方式在任何字段上强制(或清除) .showErrors(errors)
(请参阅文档 )。
This should help overcome both issues. 这应该有助于克服这两个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.