I have a situation where validating a HTML form with jQuery Validation Plugin 1.9.0. (I'm using jQuery 1.6.4). If the form is filled out correctly after the page is loaded the validation takes place on submit. The validation gives a success message, but it doesn't trigger the submitHandler. It only triggers the submitHandler if you press the submit button again.
I created a simulation on http://jsfiddle.net/peterph/Hv3xz/1/ to illustrate the problem. Can anyone tell me how I can fix this problem?
<form method="post" id="form">
<input id="E_Mail" name="E_mail" title="E_mail" required="required" /><br />
<input class="submit" type="submit" value="Send"/>
</form>
<script>
jQuery(function($) {
$("#form").submit(function(e) {
var $form = $(this);
alert('Start Validation');
$form.validate({
debug: false,
focusInvalid: false,
onfocusout: false,
onkeyup: false,
onclick: false,
rules:
{
E_mail: {required:true, email:true },
},
success: function(label) {
alert('succes:' + label);
},
submitHandler: function(form){
alert('start submitHandler');
postContent('test');
alert('end submitHandler');
},
invalidHandler: function(form, validator) {
alert('invalidHandler');
},
}).form();
alert('end Validation');
e.preventDefault();
});
});
function postContent(postData){
alert('postcontent: ' + postData);
}
</script>