验证失败时,避免将重点放在字段 [英] Prevent focus on field when it fails validation
问题描述
我经常使用此jQuery验证插件来验证表单,并且可以正常工作伟大的.真的很满意,但是当您在表单上按Submit时,它会自动将焦点放在无效的字段上.
I often use this jQuery validation plugin to validate forms and it works great. Really pleased with it, but when you press Submit on a form it automatically puts focus on the field that was invalid.
在我当前的项目中,我的表单非常长,并且当您按下提交"按钮时,滚动会跳到该字段(可能是因为它变得集中了),但是当我的表单很长时,我认为它是有点烦人.有谁知道我如何禁用jQuery验证以将注意力集中在无效的输入字段上.
On my current project I have a form wich is really long, and when you press the submit button, your scroll jumps up to the field (probably because it gets focused), but when my form is this long i think it's a bit annoying. Does anyone know how i can disable jQuery validate from putting focus on invalid input fields.
最诚挚的问候!
推荐答案
使用focusInvalid
选项并将其设置为false
:
Use the focusInvalid
option and set it to false
:
$("#abc").validate({
focusInvalid: false
});
此处的示例和
这篇关于验证失败时,避免将重点放在字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!