验证仅在提交时触发其他方法

Validation only firing on submit for additional methods

默认情况下,jQuery Validate 在 keyup 和 blur 上进行验证。这不适用于使用 addMethod 添加的自定义验证,包括包含的附加 methods.js 脚本中的所有验证。

Example plunk

在上面的示例中,电子邮件将在键入时验证,但 phone (phoneUS) 将仅在提交时验证。

如何使其他方法与内置方法完全一样?

How can I make additional methods work exactly like built-in methods?

他们已经这样做了。

问题出在您的 Plunker 中:

<input type="phoneUS" name="phone">

您没有在任何地方正确定义 phoneUS 规则,因为 type="phoneUS" 不是有效元素 type

可以使用typeclass或HTML5验证属性来定义jQuery内联验证规则.但是在这种情况下,由于没有名为 "phoneUS"type 或 HTML5 属性,因此只有 class 可以正确地内联工作...

<input type="text" class="phoneUS" name="phone">

演示:http://jsfiddle.net/w145puuz/