javascript - Jquery, prevent redirecting, validating then submit the form -
i need validate form , display errors if there are. (that part of script working)
if there no error submit form (no ajax, keep redirecting before posted data).
my actual code not redirect @ all. don't see other way using .submit() posting data.
if i'm not mistaken window.location.href not post data.
$('#contact-form').submit(function(e) { e.preventdefault(); var count_error = 0; // validating ... if(count_error == 0){ $('#contact-form').submit(); //redirecting form action posted data } });
$("#contact-form").submit(function(e) { var count_error = 0; // validating ... if (count_error == 0) { return; } e.preventdefault(); });
Comments
Post a Comment