Created
September 3, 2014 16:59
-
-
Save tomkoptel/2cd80620836e4272f124 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(".itform .send").click(function(){ | |
var form = $(this).parents(".itform"); | |
var email = form.find('input[name="email"]').val(); | |
var name = form.find('input[name="name"]').val().trim(); | |
var phone = form.find('input[name="phone"]').val().trim(); | |
var regEmail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; | |
var regPhone = /^((\+38)[\-]?)?(\(?\d{3}\)?[\- ]?)?[\d\- ]{7,10}$/ | |
var emailError = form.find('#errorMess'); | |
var nameError = form.find('#errorName'); | |
var phoneError = form.find('#errorPhone'); | |
var namephoneError = form.find("#errorNamePhone"); | |
if (name == '' && phone == '' ) { | |
namephoneError.css({display:"block"}); | |
namephoneError.css({opacity:"1"}); | |
namephoneError.animate({opacity:'0'},2000); | |
return false; | |
} | |
if (name == '') { | |
nameError.css({display:"block"}); | |
nameError.css({opacity:"1"}); | |
nameError.animate({opacity:'0'},2000); | |
return false; | |
} | |
if (phone == '') { | |
phoneError.css({display:"block"}); | |
phoneError.css({opacity:"1"}); | |
phoneError.animate({opacity:'0'},2000); | |
return false; | |
} | |
if (!regEmail.test(email)) { | |
emailError.css({display:"block"}); | |
emailError.css({opacity:"1"}); | |
emailError.animate({opacity:'0'},2000); | |
return false; | |
} | |
if (!regPhone.test(email)) { | |
phoneError.css({display:"block"}); | |
phoneError.css({opacity:"1"}); | |
phoneError.animate({opacity:'0'},2000); | |
return false; | |
} | |
else { | |
emailError.hide(); | |
$.post("./mailIT.php", $(this).parents(".itform").serialize(), function(data) { | |
_gaq.push(['_trackEvent', "Client Feedback IT School", "Email", "Email"]); | |
}); | |
form.find('.success').css({display:"block"}); | |
form.find('.success').css({opacity:"1"}); | |
form.find('.success').animate({opacity:'0'},2000); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you follow code of validation logic you will see that reg expression evaluates wrong instance.
The main problem is here.