是否可以通过jQuery-validate知道单个字段验证失败的时间 [英] Is it possible to know with jQuery-validate when a single field validation has failed

查看:100
本文介绍了是否可以通过jQuery-validate知道单个字段验证失败的时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表单,当单个字段验证失败时(例如,当用户从文件中跳出,但表单尚未提交时),我需要做其他处理. jquery-validate?

I have a form where I need to do additional processing when a single field validation has failed (when the user tabs out of the filed for instance, but the form has not been submitted) how can I hook up to this event with jquery-validate?

推荐答案

要了解表单是否存在错误,请使用:

To know if there has been an error in the form, use:

if(!$("#form0").valid()){
  //There was one or more errors in the form
}

要了解特定元素是否有错误,请使用:

To know if a specific element has an error, use:

if(!$("#form0").validate().element($("#text1"))){
  //There where some error in #text1
}

(请注意,这两种方法也会触发验证)

(Note that this two methods will also trigger validations)

希望这会有所帮助.干杯

Hope this helps. Cheers

这篇关于是否可以通过jQuery-validate知道单个字段验证失败的时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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