I agree with privacy policy
$(document).ready(function() { function isFormValid($form) { var is_correct = true; $form.find('.js-valid').each(function(){ if( $(this).val() ==" ) { $(this).addClass('errorInput'); $(this).parent().addClass('error'); is_correct = false; } }); return is_correct; }; function checkValid($form) { var iscorCheck = false; $form.find('.js-check').each(function(){ if( $(this).is(':checked')) { iscorCheck = true; }; }); return iscorCheck; }; $(".js-form-template").submit(function(e) { e.preventDefault(); $('form .js-valid').on('keyup', function(e) { var valid = true; var $proc_form = $(this).parents('form'); if(isFormValid($proc_form)) { $(this).parent().removeClass('error'); } if( $(this).val() !=" ) { $(this).removeClass('errorInput'); }; }); //Form validation var $proc_form = $(this); if(isFormValid($proc_form) && checkValid($proc_form)) { showLoad(); $.ajax({ type: "GET", url: "mail.php", data: $(this).serialize() }).done(function() { $.fancybox.close({ src: '.js-pop' }); hideLoad(); $(this).find("input").val("); $.fancybox.open({ src: '#oky' }); $(".js-form-template").trigger("reset"); }); } return false; }); });
isFormValid
^([a-z0-9]|_){1}((\\-|\\.|_*)?[a-z0-9]+)*@[a-z0-9]{1}((\\-|\\.)?[a-z0-9]+)*\\.[a-z]{2,}$