/* 
- - - - - - - - - - - - - - - - - - - - - - - -
Script de validation de formulaire en Jquery 
Vu et Reconnu 
www.Vu-Et-Reconnu.fr
- - - - - - - - - - - - - - - - - - - - - - - - 
*/
$(document).ready(function(){
	$(".contactForm").click(function(){
		valid = true;
			/* Verification d'un nom */
			if($(".name").val() == "" ){
				$(".name").next(".formulaireError").fadeIn().text("Veuillez entrer votre nom");
				valid = false;
			}
			else if (!$(".name").val().match(/^[\w\s-\'\.zéèàêâùïüë&]+$/i)){
				$(".name").next(".formulaireError").fadeIn().text("Veuillez entrer un nom valide");
				valid = false;
			}
			else{
				$(".name").next(".formulaireError").fadeOut();
			}
			/* Verification d'une email */
			if($(".email").val() == "" ){
				$(".email").next(".formulaireError").fadeIn().text("Veuillez entrer votre email");
				valid = false;
			}
			else if (!$(".email").val().match(/^[a-z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4}$/i)){
				$(".email").next(".formulaireError").fadeIn().text("Veuillez entrer une adresse valide");
				valid = false;
			}
			else{
				$(".email").next(".formulaireError").fadeOut();
			}
			/* Verification d'un numero de téléphone */
			if($(".phone").val() == "" ){
				$(".phone").next(".formulaireError").fadeIn().text("Veuillez entrer votre numero de téléphone");
				valid = false;
			}
			else if (!$(".phone").val().match(/^0[1-68]([-. ]?[0-9]{2}){4}$/i)){
				$(".phone").next(".formulaireError").fadeIn().text("Veuillez entrer un numero de téléphone valide");
				valid = false;
			}
			else{
				$(".phone").next(".formulaireError").fadeOut();
			}
			/* Verification d'un texte */
			if($(".texte").val() == "" ){
				$(".texte").next(".formulaireError").fadeIn().text("Veuillez entrer un texte");
				valid = false;
			}
			else{
				$(".texte").next(".formulaireError").fadeOut();
			}
			return valid;
	});
});

$(document).ready(function(){
	$(".infosUser").click(function(){
		valid = true;
			/* Verification d'un nom */
			if($(".name").val() == "" ){
				$(".name").next(".formulaireError").fadeIn().text("Veuillez entrer votre nom");
				valid = false;
			}
			else if (!$(".name").val().match(/^[\w\s-\'\.zéèàêâùïüë&]+$/i)){
				$(".name").next(".formulaireError").fadeIn().text("Veuillez entrer un nom valide");
				valid = false;
			}
			else{
				$(".name").next(".formulaireError").fadeOut();
			}
			/* Verification d'une email */
			if($(".email").val() == "" ){
				$(".email").next(".formulaireError").fadeIn().text("Veuillez entrer votre email");
				valid = false;
			}
			else if (!$(".email").val().match(/^[a-z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4}$/i)){
				$(".email").next(".formulaireError").fadeIn().text("Veuillez entrer une adresse valide");
				valid = false;
			}
			else{
				$(".email").next(".formulaireError").fadeOut();
			}
			/* Verification d'un numero de téléphone */
			if($(".phone").val() == "" ){
				$(".phone").next(".formulaireError").fadeIn().text("Veuillez entrer votre numero de téléphone");
				valid = false;
			}
			else if (!$(".phone").val().match(/^0[1-68]([-. ]?[0-9]{2}){4}$/i)){
				$(".phone").next(".formulaireError").fadeIn().text("Veuillez entrer un numero de téléphone valide");
				valid = false;
			}
			else{
				$(".phone").next(".formulaireError").fadeOut();
			}
			/* Verification d'un texte */
			if($(".texte").val() == "" ){
				$(".texte").next(".formulaireError").fadeIn().text("Veuillez entrer un texte");
				valid = false;
			}
			else{
				$(".texte").next(".formulaireError").fadeOut();
			}
			/* Verification d'une adresse */
			if($(".adresse").val() == "" ){
				$(".adresse").next(".formulaireError").fadeIn().text("Veuillez entrer votre adresse");
				valid = false;
			}
			else if (!$(".adresse").val().match(/^[\w\s-\'\.zéèàêâùïüë&]+$/i)){
				$(".adresse").next(".formulaireError").fadeIn().text("Veuillez entrer une adresse valide");
				valid = false;
			}
			else{
				$(".adresse").next(".formulaireError").fadeOut();
			}
			/* Verification d'un code postal */
			if($(".postal").val() == "" ){
				$(".postal").next(".formulaireError").fadeIn().text("Veuillez entrer votre code postal");
				valid = false;
			}
			else if (!$(".postal").val().match(/^([0-9]){5,6}$/i)){
				$(".postal").next(".formulaireError").fadeIn().text("Veuillez entrer un code postal valide");
				valid = false;
			}
			else{
				$(".postal").next(".formulaireError").fadeOut();
			}
			/* Verification d'une ville */
			if($(".ville").val() == "" ){
				$(".ville").next(".formulaireError").fadeIn().text("Veuillez entrer votre ville");
				valid = false;
			}
			else if (!$(".ville").val().match(/^[\w\s-\'\.zéèàêâùïüë&]+$/i)){
				$(".ville").next(".formulaireError").fadeIn().text("Veuillez entrer un nom de ville valide");
				valid = false;
			}
			else{
				$(".ville").next(".formulaireError").fadeOut();
			}
			return valid;
	});
});
