1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242
|
$(function(){
//original field values
var field_values = {
//id : value
'newPass' : 'newPass',
'newPass2' : 'newPass',
'email' : 'Votre adresse mail',
'email2' : 'Confirmer votre adresse mail',
'questsecrete' : 'Question secr\350te',
'repsecrete' : 'R\351ponse secr\350te',
'nom' : 'Votre nom',
'prenom' : 'Votre pr\351nom',
'metier' : 'Votre m\351tier',
'adresse' : 'Votre adresse',
'cp' : 'Votre Code postal',
'ville' : 'Votre ville',
'fixe' : 'Votre t\351l\351phone fixe',
'mobile' : 'Votre t\351l\351phone mobile',
'dernier_diplome' : 'Dernier diplome obtenu',
'datepickerFormation' : 'Date de d\351but',
'datepickerFormation2' : 'Date de fin',
'datepicker' : 'Date de d\351but',
'datepicker2' : 'Date de fin',
'intitule_poste' : 'Intitul\351 du poste',
'entreprise' : 'Entreprise',
'domaine_acti' : 'Domaine activit\351',
'result' : 'result'
};
//inputfocus
$('input#newPass').inputfocus({ value: field_values['newPass'] });
$('input#newPass2').inputfocus({ value: field_values['newPass2'] });
$('input#email').inputfocus({ value: field_values['email'] });
$('input#email2').inputfocus({ value: field_values['email2'] });
$('input#questsecrete').inputfocus({ value: field_values['questsecrete'] });
$('input#repsecrete').inputfocus({ value: field_values['repsecrete'] });
$('input#nom').inputfocus({ value: field_values['nom'] });
$('input#prenom').inputfocus({ value: field_values['prenom'] });
$('input#adresse').inputfocus({ value: field_values['adresse'] });
$('input#cp').inputfocus({ value: field_values['cp'] });
$('input#ville').inputfocus({ value: field_values['ville'] });
$('input#fixe').inputfocus({ value: field_values['fixe'] });
$('input#mobile').inputfocus({ value: field_values['mobile'] });
$('input#dernier_diplome').inputfocus({ value: field_values['dernier_diplome'] });
$('input#datepickerFormation').inputfocus({ value: field_values['datepickerFormation'] });
$('input#datepickerFormation2').inputfocus({ value: field_values['datepickerFormation2'] });
$('input#datepicker').inputfocus({ value: field_values['datepicker'] });
$('input#datepicker2').inputfocus({ value: field_values['datepicker2'] });
$('input#intitule_poste').inputfocus({ value: field_values['intitule_poste'] });
$('input#entreprise').inputfocus({ value: field_values['entreprise'] });
$('input#domaine_acti').inputfocus({ value: field_values['domaine_acti'] });
//reset progress bar
$('#progress').css('width','0');
$('#progress_text').html('0% Complete');
//first_step
$('form.inscription').submit(function(){ return false; });
$('#submit_first').click(function(){
//remove classes
$('#first_step input').removeClass('error').removeClass('valid');
//ckeck if inputs aren't empty
var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
var fields = $('#first_step input[type=text], #first_step input[type=password]');
var error = 0;
$.post("requete2.php", { email: $("#email").val() },
function(data) {
$("#result").html(data);
});
fields.each(function(){
var value = $(this).val();
if( $("#validite").text() == "email non disponible" || value.length<4 || value==field_values[$(this).attr('id')] || ( $(this).attr('id')=='email' && !emailPattern.test(value) ) || $('#email').val() != $('#email2').val() ){
$(this).addClass('error');
$(this).effect("shake", { times:3 }, 50);
error++;
} else {
$(this).addClass('valid');
}
});
if(!error) {
if( $('#newPass').val() != $('#newPass2').val() ) {
$('#first_step input[type=password]').each(function(){
$(this).removeClass('valid').addClass('error');
$(this).effect("shake", { times:3 }, 50);
});
return false;
} else {
//update progress bar
$('#progress_text').html('33% Complete');
$('#progress').css('width','113px');
//slide steps
$('#first_step').slideUp();
$('#second_step').slideDown();
}
} else return false;
});
$('#submit_second').click(function(){
//remove classes
$('#second_step input').removeClass('error').removeClass('valid');
var cpPattern = /^((0[1-9])|([1-8][0-9])|(9[0-8])|(2A)|(2B))[0-9]{3}$/;
var fixePattern = /^0[1-89]([\.|\-|\s]*[0-9]{2}){4}$/;
var mobilePattern = /^0[6-7]([\.|\-|\s]*[0-9]{2}){4}$/;
var fields = $('#second_step input[type=text]');
var error = 0;
fields.each(function(){
var value = $(this).val();
if(($(this).attr('id')=='cp' && !cpPattern.test(value)) || ($(this).attr('id')=='fixe' && !fixePattern.test(value)) || ($(this).attr('id')=='mobile' && !mobilePattern.test(value))|| value.length<1 || value==field_values[$(this).attr('id')]) {
$(this).addClass('error');
$(this).effect("shake", { times:3 }, 50);
error++;
} else {
$(this).addClass('valid');
}
});
if(!error) {
//update progress bar
$('#progress_text').html('66% Complete');
$('#progress').css('width','226px');
//slide steps
$('#second_step').slideUp();
$('#third_step').slideDown();
} else return false;
});
$('#submit_third').click(function(){
//remove classes
$('#third_step input').removeClass('error').removeClass('valid');
var fields = $('#third_step input[type=text]');
var error = 0;
fields.each(function(){
var value = $(this).val();
if( value.length<6 || value==field_values[$(this).attr('id')]) {
$(this).addClass('error');
$(this).effect("shake", { times:3 }, 50);
error++;
} else {
$(this).addClass('valid');
}
});
if(!error) {
//update progress bar
$('#progress_text').html('100% Complete');
$('#progress').css('width','339px');
//prepare the fourth step
var fields = new Array(
$('#agence').val().substr(3),
$('#email').val(),
$('#newPass').val(),
$('#questsecrete').val(),
$('#repsecrete').val(),
$('#civilite').val() + ' ' + $('#nom').val() + ' ' + $('#prenom').val(),
$('#metier').val().substr(2),
$('#annee_exp').val(),
$('#jour').val() + '/' + $('#mois').val() + '/' + $('#annee').val(),
$('#adresse').val(),
$('#cp').val(),
$('#ville').val(),
$('#fixe').val(),
$('#mobile').val(),
$('#idmoyenContact').val().substr(3),
$('#dernier_diplome').val(),
$('#datepickerFormation').val(),
$('#datepickerFormation2').val(),
$('#intitule_poste').val(),
$('#entreprise').val(),
$('#datepicker').val(),
$('#datepicker2').val(),
$('#domaine_acti').val()
);
var tr = $('#fourth_step tr');
tr.each(function(){
//alert( fields[$(this).index()] )
$(this).children('td:nth-child(2)').html(fields[$(this).index()]);
});
//slide steps
$('#third_step').slideUp();
$('#fourth_step').slideDown();
} else return false;
});
$('#submit_fourth').click(function(){
$('form.inscription').submit( function(e) {
e.preventDefault(); // on empeche l'envoi du formulaire par le navigateur
var datas = $(this).serialize();
$.ajax({
type: 'POST', // envoi des données en POST
url: $(this).attr('action'), // envoi au fichier défini dans l'attribut action
data: datas, // sélection des champs à envoyer
success: function(msg) { // callback en cas de succès
alert('success : '+'Votre inscription a \351t\351 pris en compte, vous pouvez maintenant vous connecter \340 votre espace');
location.href = 'index.php' ;
}
});
});
});
}); |