var script = document.createElement("script"); script.src = "https://code.jquery.com/jquery-3.2.1.min.js"; script.type = "text/javascript"; var barIsDeclared = true; try{ niveau; } catch(e) { if(e.name == "ReferenceError") { barIsDeclared = false; } } if (barIsDeclared==false) { var niveau=0; } document.getElementsByTagName("head")[0].appendChild(script); document.write("
"); document.write(""); document.write(""); document.write(""); if (niveau>0) { document.write(""); } else { document.write(""); document.write(""); } document.write("");document.write("");document.write("
Votre Prénom :
Votre Nom de famille :
Votre email :
Votre niveau de pratique :
Votre téléphone portable :

Vous n'avez pas rempli correctement les champs du formulaire !

"); function defer(method) { if (window.jQuery) { method(); } else { setTimeout(function() { defer(method) }, 50); } } defer(function () { $(document).ready(function(){ var $prenom = $("#prenom"), $nom = $("#nom"), $email = $("#email"), $champ = $(".champ"); $telportable = $("#telportable"), $champ = $(".champ"), $envoi = $("#envoi"), $erreur = $("#erreur"); $erreur.css("display", "none"); $champ.keyup(function(){ if($(this).val().length < 5){ // si la chaîne de caractères est inférieure à 5 $(this).css({ // on rend le champ rouge borderColor : "red", color : "red" }); } else{ $(this).css({ // si tout est bon, on le rend vert borderColor : "green", color : "green" }); } }); $envoi.click(function(e){ verifier($prenom); verifier($nom); verifier($email,"email"); // verifier($telportable,"tel"); if ($erreur.css("display")== "block") e.preventDefault(); }); function verifier(champ,type){ $erreur.css("display", "none"); if(champ.val() == ""){ // si le champ est vide $erreur.text("champ "+champ[0].id+" non valide !"); $erreur.css("display", "block"); // on affiche le message d erreur champ.css({ // on rend le champ rouge borderColor : "red", color : "red" }); } if (type=="email") { if (isEmail(champ.val())==false) { $erreur.css("display", "block"); $erreur.text("champ email non valide !"); champ.css({ // on rend le champ rouge borderColor : "red", color : "red" }); } } } }); }); function isPhone(txtPhone) { var filter = /^((\+[1-9]{1,4}[ \-]*)|(\([0-9]{2,3}\)[ \-]*)|([0-9]{2,4})[ \-]*)*?[0-9]{3,4}?[ \-]*[0-9]{3,4}?$/; if (filter.test(txtPhone)) { return true; } else { return false; } } function isEmail(email) { var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; return regex.test(email); }