You should check to see if there are any errors before returning false
$(function () {
$("#contactform").submit(function () {
$(":input").not("[type=submit]").removeClass('error').each(function () {
if ($.trim($(this).val()).length == 0) $(this).addClass('error');
});
// if there is anything with a class of error inside the form
// can also use $(this).find('.error') - it's the same thing
if($('.error',this).length){
// then return false
return false;
}
});
});
solved Form won’t submit return false; [closed]