jQuery delay error with Form Validator Plugin
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?
Here's an approach:
$(document).ready(function() {
$("#job_submit").click(function() {
// click all the errors at once
$('.formError').delay(3000).trigger('click');
});
});
精彩评论