//****************************************************************************** //******* Iconeweb - Pijo - 04/08/2008 //******* ------------------------------------------------------------- //******* Application : Project //******* Objet de la page : Fonctions et procédures javascript //******* de la page creation_modification //******* Révisions : (date) - (objet) //******* //******* //******* //****************************************************************************** //****************************************************************************** //** Initialisation et éventuellement valeurs par défaut des variables communes //****************************************************************************** //****************************************************************************** //** Confirmation et vérification de l'envoi, et envoi //****************************************************************************** function f_VerifierChampsEtEnvoyer () { var erreurpresente = false ; var msgerreur = "The following errors have been found in the form :\n\n" ; var obligatoire = false ; var champfocus = "" ; // kkk if (document.form_creation_modification.s_Creation_Nouvel_Enregistrement.value != 1) { if (f_Trim(document.form_creation_modification.s_pseudo.value) == "") { erreurpresente = true ; msgerreur = msgerreur + "- You must fill in the field : user name \n" ; if (champfocus == "") champfocus = "s_pseudo" ; } if (f_Trim(document.form_creation_modification.s_motdepasse.value) == "") { erreurpresente = true ; msgerreur = msgerreur + "- You must fill in the field : password \n" ; if (champfocus == "") champfocus = "s_motdepasse" ; } if (f_Trim(document.form_creation_modification.s_nom.value) == "") { erreurpresente = true ; msgerreur = msgerreur + "- You must fill in the field : name \n" ; if (champfocus == "") champfocus = "s_nom" ; } if (f_Trim(document.form_creation_modification.s_prenom.value) == "") { erreurpresente = true ; msgerreur = msgerreur + "- You must fill in the field : first name \n" ; if (champfocus == "") champfocus = "s_prenom" ; } if (f_Trim(document.form_creation_modification.s_email.value) == "") { erreurpresente = true ; msgerreur = msgerreur + "- You must fill in the field : e-mail \n" ; if (champfocus == "") champfocus = "s_email" ; } if (!f_TestEmail(document.form_creation_modification.s_email.value) && (!(document.form_creation_modification.s_email.value == ""))) { erreurpresente = true ; msgerreur = msgerreur + "- Field e-mail is not a valid email address\n" ; if (champfocus == "") champfocus = "s_email" ; } if (f_Trim(document.form_creation_modification.s_email.value) != f_Trim(document.form_creation_modification.s_email_confirmation.value)) { erreurpresente = true ; msgerreur = msgerreur + "- les adresses e-mail ne sont pas identiques\n" ; if (champfocus == "") champfocus = "s_email" ; } if (!f_Trim(document.form_creation_modification.s_datenaissance.value)) { erreurpresente = true ; msgerreur = msgerreur + "- You must fill in the field : birth date \n" ; if (champfocus == "") champfocus = "s_datenaissance" ; } if (document.form_creation_modification.s_condition.checked == false) { erreurpresente = true ; msgerreur = msgerreur + "- Merci de valider les conditions générales \n" ; } } else { if (f_Trim(document.form_creation_modification.s_pseudo.value) == "") { erreurpresente = true ; msgerreur = msgerreur + "- You must fill in the field : user name \n" ; if (champfocus == "") champfocus = "s_pseudo" ; } if (f_Trim(document.form_creation_modification.s_motdepasse.value) == "") { erreurpresente = true ; msgerreur = msgerreur + "- You must fill in the field : password \n" ; if (champfocus == "") champfocus = "s_motdepasse" ; } if (f_Trim(document.form_creation_modification.s_motdepasse_confirme.value) == "") { erreurpresente = true ; msgerreur = msgerreur + "- You must fill in the field : confirm your password \n" ; if (champfocus == "") champfocus = "s_motdepasse_confirme" ; } if (f_Trim(document.form_creation_modification.s_motdepasse.value) != f_Trim(document.form_creation_modification.s_motdepasse_confirme.value)) { erreurpresente = true ; msgerreur = msgerreur + "- Attention, voz mots de passe sont différents. Merci de corriger \n" ; document.form_creation_modification.s_motdepasse.value = ""; document.form_creation_modification.s_motdepasse_confirme.value = ""; if (champfocus == "") champfocus = "s_motdepasse" ; } if (f_Trim(document.form_creation_modification.s_nom.value) == "") { erreurpresente = true ; msgerreur = msgerreur + "- You must fill in the field : name \n" ; if (champfocus == "") champfocus = "s_nom" ; } if (f_Trim(document.form_creation_modification.s_prenom.value) == "") { erreurpresente = true ; msgerreur = msgerreur + "- You must fill in the field : first name \n" ; if (champfocus == "") champfocus = "s_prenom" ; } if (f_Trim(document.form_creation_modification.s_email.value) == "") { erreurpresente = true ; msgerreur = msgerreur + "- You must fill in the field : e-mail \n" ; if (champfocus == "") champfocus = "s_email" ; } if (!f_TestEmail(document.form_creation_modification.s_email.value) && (!(document.form_creation_modification.s_email.value == ""))) { erreurpresente = true ; msgerreur = msgerreur + "- Field e-mail is not a valid email address\n" ; if (champfocus == "") champfocus = "s_email" ; } if (f_Trim(document.form_creation_modification.s_email.value) != f_Trim(document.form_creation_modification.s_email_confirmation.value)) { erreurpresente = true ; msgerreur = msgerreur + "- les adresses e-mail ne sont pas identiques\n" ; if (champfocus == "") champfocus = "s_email" ; } if (!f_Trim(document.form_creation_modification.s_datenaissance.value)) { erreurpresente = true ; msgerreur = msgerreur + "- You must fill in the field : birth date \n" ; if (champfocus == "") champfocus = "s_datenaissance" ; } if (document.form_creation_modification.s_condition.checked == false) { erreurpresente = true ; msgerreur = msgerreur + "- Merci de valider les conditions générales \n" ; } } /* if (!f_captcha_est_correct()) { erreurpresente = true ; msgerreur = msgerreur + "- Texte Captcha incorrect\n" ; if (champfocus == "") champfocus = "s_code_captcha" ; } */ // soumission du formulaire if (erreurpresente == false) { document.getElementById("form_creation_modification").submit(); return true; } else { msgerreur = msgerreur + "\nPlease check your typing and send the form again." ; alert(msgerreur) ; eval("document.getElementById('form_creation_modification')." + champfocus + ".select()") ; eval("document.getElementById('form_creation_modification')." + champfocus + ".focus()") ; return false; } } // fin f_VerifierChampsEtEnvoyer function f_EnvoyerCreationModification() { if (document.getElementById("form_creation_modification").s_Creation_Nouvel_Enregistrement != "") { return f_VerifierChampsEtEnvoyer () ; } if (confirm("Are you sure you want to modify the following registration (this is an irreversible operation) ?")) { return f_VerifierChampsEtEnvoyer () ; } // fin if confirm } // fin f_EnvoyerModifications function f_controle_pseudo() { if (f_Trim(document.form_creation_modification.s_pseudo.value) == "") { messagepseudo = "You must fill in the field : user name \n" ; document.getElementById('champ_pseudo_libelle').style.color = 'red'; alert(messagepseudo); champfocus = "s_pseudo" ; eval("document.getElementById('form_creation_modification').s_pseudo.focus()") ; return false; } else if(((f_Trim(document.form_creation_modification.s_pseudo.value)).length) < 3) { messagepseudo = "Le pseudo doit contenir 3 caractères minimum \n" ; document.getElementById('champ_pseudo_libelle').style.color = 'red'; alert(messagepseudo); champfocus = "s_pseudo" ; eval("document.getElementById('form_creation_modification').s_pseudo.focus()") ; return false; } else if (f_espace_pseudo(f_Trim(document.form_creation_modification.s_pseudo.value))) { messagepseudo = "le pseudo ne peut contenir un caractère autre que A à Z ou a à z ou 0 à 9 ou _ ou . ou @ \n" ; document.getElementById('champ_pseudo_libelle').style.color = 'red'; document.form_creation_modification.s_pseudo.style.backgroundColor = '#C7EDF2'; alert(messagepseudo); champfocus = "s_pseudo" ; eval("document.getElementById('form_creation_modification').s_pseudo.focus()") ; return false; } else if (((f_Trim(document.form_creation_modification.s_motdepasse.value)).length) < 6) { messagepseudo = "le mot de passe doit contenir au moins 6 caractères \n" ; alert(messagepseudo); champfocus = "s_motdepasse" ; eval("document.getElementById('form_creation_modification').s_motdepasse.focus()") ; return false; } else { var pseudo = document.form_creation_modification.s_pseudo.value; var url = "verif_pseudo_unique.php?pseudo="+pseudo; new Ajax.Request(url, { method : 'get', onSuccess: function(transport) { if (transport.responseText.match('done')) { f_controle_email() ; } else { document.getElementById('champ_pseudo_libelle').style.color = 'red'; document.form_creation_modification.s_pseudo.style.backgroundColor = '#C7EDF2'; alert("Ce pseudo est déjà utilisé"); } } }); } } function f_controle_email() { var email = document.form_creation_modification.s_email.value; var url = "verif_email_unique.php?email="+email; new Ajax.Request(url, { method : 'get', onSuccess: function(transport) { if (transport.responseText.match('done')) { f_VerifierChampsEtEnvoyer() ; } else { document.getElementById('champ_email_libelle').style.fontWeight = 'bold'; document.getElementById('champ_email_libelle').style.color = 'red'; document.form_creation_modification.s_email.style.backgroundColor = '#C7EDF2'; alert("cette adresse e-mail est déjà utilisée pour un compte\nveuillez choisir une autre adresse."); } } }); } function f_espace_pseudo(p_texte) { // test si au moins un caractère autre que A à Z ou a à z ou 0 à 9 ou _ ou . ou @ a été saisi var regExpression=/[^A-Za-z0-9_\.@]+/; if (regExpression.test(p_texte)) return true; return false; }