I am trying to check the "email" field and send the form if the "email" is not empty and valid. But for some reason the form is not sent.
var validEmail = 0; $("input[name='email']").blur(function() { if($(this).val() != '') { var pattern = /^([a-z0-9_\.-])+@[a-z0-9-]+\.([az]{2,4}\.)?[az]{2,4}$/i; if(pattern.test($(this).val())){ validEmail = 1; $(this).removeClass("error"); } else { validEmail = 0; $(this).addClass("error"); } } else { validEmail = 0; $(this).addClass("error"); } }); $("input[type='submit']").click(function(e) { e.preventDefault(); if (validEmail == 1) { $(this).parents(".order_form").submit(); } else { $(this).parents(".order_form").find("input[name='email']").addClass("error"); $(this).parents(".order_form").find("input[name='email']").focus(); } }); The form was found correctly, because if instead of submit () write hide () , then it is hidden.
e.preventDefault();put inelse? - Crantisz