表单验证器插件的 jQuery 延迟错误
我有一个使用 ZURB.org 脚本的弹出框(工作得很好)。在这个显示框中,我有一个表格,用户可以填写某些信息。这可以完美地使用该插件进行验证 - 呈现出漂亮且对齐的错误消息。
我的问题是,由于这是一个显示框,当用户单击显示框(退出)时,验证图标仍然显示在那里,直到用户手动单击它们。
我已经设法弄清楚,如果他们单击框顶部的“退出”图标,它将通过以下代码关闭它们:
<a class="close-reveal-modal" onclick="$('#jobForm').validationEngine('hideAll');">Exit</a>
然而,我现在想使用一些 jQuery 来自动“隐藏”这些比如说 3 秒后出现错误消息。
到目前为止,我的代码是:
<script>
$(document).ready(function() {
$("#job_submit").click(function() {
$('#jobForm').validationEngine('hideAll').delay(3000);
});
});
</script>
job_submit 是表单中“提交”按钮的 ID 和名称。我使用 Chrome 调试工具更进一步,在控制台中编写了以下代码:
$('#jobForm').validationEngine('hideAll').delay(3000);
当存在表单验证错误时。返回错误“类型错误”。
从现在起我不确定如何解决这个类型错误。
一如既往,非常感谢您的帮助。
更新
Div 类的命名不相同,由于某种原因,div 的第一部分是表单字段本身的名称,例如 jdesformErrorparentFormjobForm formError
但是,最后 2 部分似乎是一致的。
我在控制台中尝试过这个 - $('.jdesformError ParentFormjobForm formError').delay(1000).trigger('click');
它顺利通过了,但是,当我物理单击它时,“错误”字段并没有消失,这是否与我正在使用的显示框有关?
I have a pop-up box using the ZURB.org script (working perfectly fine). Within this reveal box I have a Form which the user can fill out certain information. This validates perfectly using the plugin - presenting the nice looking error messages aligned fine.
My problem is, with this been a reveal box, when the user clicks out of the reveal box (to exit) the validation icons still appear there until the user manually clicks them.
I've managed to figure out if they click the 'Exit' icon at the top of the box, it will close them by means of this code:
<a class="close-reveal-modal" onclick="$('#jobForm').validationEngine('hideAll');">Exit</a>
How ever, I now want to use a bit of jQuery to automatically 'Hide' these error messages after, lets say, 3 seconds.
The code I have so far is:
<script>
$(document).ready(function() {
$("#job_submit").click(function() {
$('#jobForm').validationEngine('hideAll').delay(3000);
});
});
</script>
job_submit is the ID and name of the Submit button within the form. I went one step further with Chromes debugging tool and wrote within the console the following code:
$('#jobForm').validationEngine('hideAll').delay(3000);
When the form validation errors were present. This came back with the error 'Type Error'.
From this point on I am unsure as to how to solve this Type Error.
As always, many thanks for your help.
Update
The Div Classes are not named the same, for some reason, the first part of the div is the name of the form field itsself e.g jdesformError parentFormjobForm formError
How ever, the last 2 sections appear to be consistent.
I tried this in the console -
$('.jdesformError parentFormjobForm formError').delay(1000).trigger('click');
and it passed with flying colours however, the 'error' field didn't vanish when it does when i physically click it, would it be something to do with the reveal box i'm using?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一种方法:
Here's an approach: