function hidePopup() { var popup = document.getElementById('back_popup'); popup.style.display = 'none'; } function showPopup(message) { var popup = document.getElementById('back_popup'); var msg = document.getElementById('message'); popup.style.display = 'block'; msg.innerHTML = message; } function validateLoginForm() { var email = document.getElementById('email'); var emailDiv = document.getElementById('log_4'); if (emailDiv.style.display == 'block' && !isValidMail(email.value)) return 'Votre email n\'est pas dans un format valide, veuillez le ressaisir.'; return 1; } function validateForm(errorCode) { /* errorCode -6 : mail utilisé par un autre membre -7 : pseudo utilisé par un autre membre -8 : mail utilisé par un autre membre comme email_temp -9 : code postal non valide -10 : login incorrect -11 : compte désactivé par la modération -12 : compte désactivé par la modération */ var sexCode = 0; var sexCodeOther = 0; var login = document.getElementById('login'); var mail = document.getElementById('mail'); var agemin = document.getElementById('agemin'); var agemax = document.getElementById('agemax'); var year = document.getElementById('year'); var month = document.getElementById('month'); var day = document.getElementById('day'); var birthday = year.value+'-'+month.value+'-'+day.value; var country = document.getElementById('country'); var zipCode = document.getElementById('zip'); var cgu = document.getElementById('major'); if (document.getElementById('sex_code1').checked) sexCode = 1; else if (document.getElementById('sex_code2').checked) sexCode = 2; else sexCode = 0; if (document.getElementById('sex_codeother1').checked) sexCodeOther = 1; else if (document.getElementById('sex_codeother2').checked) sexCodeOther = 2; else sexCodeOther = 0; if (sexCode == 0) { disableIndicator(0); return 'Veuillez renseigner votre sexe.'; } if (sexCodeOther == 0) { disableIndicator(1); return 'Veuillez renseigner le sexe de la personne recherchée.'; } if (agemin.value > agemax.value) { disableIndicator(2); return 'Votre intervalle n\'est pas cohérent, l\'âge minimal doit être inférieur à l\'âge maximal.'; } if (!isValidLogin(login.value) || errorCode==-7 || errorCode==-10 || errorCode==-11 || errorCode==-12) { disableIndicator(3); return 'Veuillez saisir un pseudonyme ne contenant que des chiffres et des lettres non accentuées.'; } if (!isValidMail(mail.value) || errorCode==-6 || errorCode==-8) { disableIndicator(4); return 'Votre email n\'est pas dans un format valide, veuillez le ressaisir.'; } if (!isValidBirthday(birthday)) { disableIndicator(5); return 'Vous devez avoir au moins 18 ans pour vous inscrire sur le site.'; } if (country.value == 0) { disableIndicator(6); return 'Vous devez renseigner votre pays de résidence.'; } if (zipCode.value == '' || errorCode==-9) { disableIndicator(7); return 'Vous devez renseigner un code postal valide.'; } if (!cgu.checked) return 'Vous devez accepter les CGU.'; return 1; } function validateInitPassword(type) { var currentPassword = document.getElementById('currentPassword'); var newPassword1 = document.getElementById('newPassword1'); var newPassword2 = document.getElementById('newPassword2'); var uid = document.getElementById('uid'); if (!isValidUid(uid.value)) return 'L\'identifiant uid n\'est pas renseigné.'; if (type == '3' && !isValidPassword(currentPassword.value)) return 'Votre mot de passe actuel doit contenir au moins 6 caractères.'; if (!isValidPassword(newPassword1.value)) return 'Votre nouveau mot de passe doit contenir au moins 6 caractères.'; if (!isValidPassword(newPassword2.value)) return 'Votre nouveau mot de passe doit contenir au moins 6 caractères.'; if (!isSamePassword(newPassword1.value,newPassword2.value)) return 'Les mots de passe saisis ne sont pas identiques, veuillez les ressaisir.'; return 1; } function disableIndicator(ind) { var elmt; for (i=0; i<=7; i++) { elmt = document.getElementById("indicator_"+i); if (elmt != null) { if (i == ind) elmt.style.visibility = 'visible'; else elmt.style.visibility = 'hidden'; } } } function isValidMail(mail) { var mailRegExp = /^[._a-z0-9-]+@(([a-z0-9-]+\.)*([a-z0-9-]+)(\.[a-z]{2,3}))$/i; if (mail=='') return false; else return mailRegExp.test(mail); } function isValidBirthday(birthday) { if(birthday.length != 10) return false; else { usrYear = parseInt(birthday.substring(0,4)); usrMonth = parseInt(birthday.substring(5,7)); usrDay = parseInt(birthday.substring(8,10)); usrNbDay = parseInt(usrDay + 31*usrMonth + usrYear*12*31); todayYear = parseInt('2010-09-07'.substring(0,4)); todayMonth = parseInt('2010-09-07'.substring(5,7)); todayDay = parseInt('2010-09-07'.substring(8,10)); todayNbDay = parseInt(todayDay + 31*todayMonth + todayYear*12*31); if (todayNbDay - usrNbDay < 18*12*31) return false; else return true; } } function isValidPassword(password) { if (password=='' || password.length < 6) return false; else return true; } function isSamePassword(password1, password2) { if (password1 == password2) return true; else return false; } function isValidUid(uid) { if (uid == '') return false; else return true; } function isValidLogin(login) { var regexp = /[^a-zA-Z0-9]/; if (login == '') return false; else return !regexp.test(login); }