The form is validated before submit with this plugin. And submitted as shown in the code:
jQuery.validator.setDefaults({
submitHandler: function(){
jQuery("form").submit(function(e) {
e.preventDefault();
jQuery.post(base_url + "blog/ajax_comment", { author: jQuery("#author").val(), email: jQuery("#email").val(), url: jQuery("#url").val(), message: jQuery("#message").val() , post_ID: jQuery("#post_ID").val(), not: jQuery("#not").val() }, function (data) {
//do stuff here
});
});
}
});
jQuery().ready(function() {
// validate the comment form when it is submitted
jQuery("#commentform").validate();
});
In order to be submitted, I need to press the submit button twice. I am kind of new to jQuery, and I can't really tell why is that. Is there an easy way to fix this?