jQuery closing pop-up after successful form submit
- by RyanP13
Hi,
I have a pop up form that i wish to close on successfull submit of the form. Currently we are only validating on the server side which will create an unordered list of validation errors with the class .error_message.
Once the form has been successfully submitted i want to close the window.
Currently the jQuery i am using for this is as follows but does not work because the first time the form has been submitted the number of error messages will always be zero.
$(document).ready(function() {
$('form#emailQuote').submit(function() {
var $emailErrors = $('form#emailQuote ul.error_message').length;
alert($emailErrors);
if ($emailErrors == 0) {
//window.close();
alert('no errors');
} else {
//alert('errors');
alert('errors');
}
});
});